我刚被这辆车撞到了。
结果是在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>;但这不是真正的解决方案,或我认为的问题...
我该如何解决这个问题呢?
发布于 2019-05-15 01:20:19
看起来像是this commit删除了所有模板值并导致了中断。我能够通过向包中显式地添加一个版本(2.0.15)来解决这个问题。
npm install @types/react-transition-group@2.0.15
2.0.15是工作正常的最新版本。2.0.16和更新版本包含错误提交。
发布于 2019-02-15 07:49:59
我也遇到了同样的问题,刚才有一个@types/recompose模块报告了一个离奇相似的issue。作为临时修复,我卸载了@types/react-transition-group,并在我的项目根目录下添加了一个包含以下内容的types/react-transition-group.d.ts文件:
declare module 'react-transition-group' {
export const CSSTransitionGroup: any
}当然,您将丢失您自己不提供的所有类型提示,因此,如果recompose问题不相关,也可以提前通知GitHub代码库,这样他们就可以提供修复。
https://stackoverflow.com/questions/54698733
复制相似问题