react hook form和typescript-property';inputRef';类型DetailedHTMLProps上不存在

react hook form和typescript-property';inputRef';类型DetailedHTMLProps上不存在,typescript,react-hook-form,react-forwardref,Typescript,React Hook Form,React Forwardref,这是我的反应钩控制器 ( )} /> 问题是ref不起作用。它需要是inputRef-由react hook表单示例确定。 如果使用inputRef,则会出现类型脚本错误: 类型“DetailedHTMLProps”上不存在属性“inputRef” 如果我尝试将该属性添加到index.d.ts文件中,它会破坏所有其他声明的模块 declare module 'react' { import React from 'react'; interface HTMLInputAttribut

这是我的反应钩控制器

(
)}
/>
问题是ref不起作用。它需要是inputRef-由react hook表单示例确定。 如果使用inputRef,则会出现类型脚本错误:

类型“DetailedHTMLProps”上不存在属性“inputRef”

如果我尝试将该属性添加到index.d.ts文件中,它会破坏所有其他声明的模块

declare module 'react' {
  import React from 'react';

  interface HTMLInputAttributes<T> extends React.HTMLAttributes<T> {
    // extends React's HTMLAttributes
    inputRef?: any;
  }
}

declare module '*.svg' {
  const content: any;
  export const ReactComponent: any;
  export default content;
}

声明模块“react”{
从“React”导入React;
接口HTMLInputAttributes扩展React.HTMLAttributes{
//扩展React的HtmLatAttributes
输入?:任何;
}
}
声明模块“*.svg”{
常量内容:任意;
导出常量组件:任意;
导出默认内容;
}

我把ref放在了控制器上,而它本应该在输入本身中。 修正:

(
)}