【问题标题】:Failures in Definitely Typed packages definitions绝对类型包定义中的失败
【发布时间】:2020-03-28 16:22:43
【问题描述】:

我正在开发一个项目,该项目使用来自确定类型存储库的多个包。但是这些类型在我的项目中工作不正确。例如,它说:
JSX element type 'Component<any, ComponentState> | ReactElement<any>' is not a constructor function for JSX elements.
当我尝试渲染一个键入为React.ComponentType. 的变量时

另外,我的 typescript 版本在确定类型的包 *.d.ts 文件中发现了多个错误。例如,它在 react 的 index.d.ts 中的错误之一是:
Type 'ChangeTargetHTMLAttributes<T>' does not satisfy the constraint 'DOMAttributes<T>'. Types of property 'onChange' are incompatible.

我也遇到了与react-transition-groupgatsby 等多个其他类型定义相同的问题。

我正在使用锁定在v3.7.2 中的特定于工作区的打字稿版本。而且我在 package.json 文件中找不到 @types/react 包作为依赖项,但可以在 node_modules/types/react 文件夹中找到它。

【问题讨论】:

    标签: reactjs typescript definitelytyped


    【解决方案1】:

    删除 yarn.lock 并重新安装没有锁的 node_modules 后修复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-25
      • 1970-01-01
      相关资源
      最近更新 更多