Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@types/react-transition-group: Generic type 'ReactElement<P, T>' requires between 1 and 2 type arguments.ts(2707)

I've just got hit with this one.

Turns out that in the file node_modules/@types/react-transition-group/TransitionGroup.d.ts

There is this type:

  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;
    };

And this is making the compilation fail with this error:

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.

I've found that if I replace this:

childFactory?(child: ReactElement): ReactElement; 

for this:

childFactory?(child: ReactElement<any, any>): ReactElement<any, any>;

But this is not the real solution, or problem I think...

How should I fix this?

like image 658
danielrvt Avatar asked Feb 14 '19 20:02

danielrvt


1 Answers

It looks like this commit removed all the template values and caused the break. I was able to resolve this by explicitly adding a version (2.0.15) to the package.

npm install @types/[email protected]

2.0.15 is the latest that works. 2.0.16 and newer contains the bad commit.

like image 55
Sat Thiru Avatar answered Nov 15 '22 22:11

Sat Thiru