reactjs - @types/react-transition-group:通用类型 'ReactElement
' 需要 1 到 2 个类型的 arguments.ts(2707)
问题描述
我刚刚被这个击中了。
原来在文件中node_modules/@types/react-transition-group/TransitionGroup.d.ts
有这种类型:
type TransitionGroupProps<T extends keyof JSX.IntrinsicElements = "div", V extends ReactType = any> =
(IntrinsicTransitionGroupProps<T> & JSX.IntrinsicElements[T]) | (ComponentTransitionGroupProps<V>) & {
children?: ReactElement<TransitionProps> | Array<ReactElement<TransitionProps>>;
childFactory?(child: ReactElement): ReactElement;
[prop: string]: any;
};
这使编译失败并出现此错误:
ERROR in [at-loader] ./node_modules/@types/react-transition-group/TransitionGroup.d.ts:16:30
TS2707: Generic type 'ReactElement<P, T>' requires between 1 and 2 type arguments.
ERROR in [at-loader] ./node_modules/@types/react-transition-group/TransitionGroup.d.ts:16:45
TS2707: Generic type 'ReactElement<P, T>' requires between 1 and 2 type arguments.
我发现如果我替换它:
childFactory?(child: ReactElement): ReactElement;
为了这:
childFactory?(child: ReactElement<any, any>): ReactElement<any, any>;
但这不是真正的解决方案,或者我认为的问题......
我应该如何解决这个问题?
解决方案
看起来此提交删除了所有模板值并导致中断。我能够通过向包中显式添加版本(2.0.15)来解决此问题。
npm install @types/react-transition-group@2.0.15
2.0.15 是最新的。2.0.16 和更新版本包含错误提交。
推荐阅读
- magento2 - 如何通过 mixin 将新的 JS 函数添加到 Magento 结帐付款页面的运输信息部分?
- r - 突变为将文本字段转换为包装字符串
- typescript - 用于反应打字稿的 scss 文件中的 @import
- reactjs - 将 API 信息映射到 React 组件
- python - 如何合并熊猫数据框的两个子集并按原始索引排序?
- rust - 在 Rust 中将随机生成的 int (i32) 转换为字符串时遇到问题
- python - 从pdf文件中的锚链接目标获取页码
- wordpress - Wordpress postmeta 序列化问题
- python - 没有动态规划的最长公共子序列
- python - 如何在启动时将参数传递给android应用程序?