9

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?

danielrvt
  • 8,650
  • 14
  • 65
  • 110
  • Running into something very similar with@types/react-select 2.0.17 (see my other post on that). Was able to fix that by downgrading to a lower version (2.0.8). thru trial and error. However, react-select depends on @types/react-transition-group (at version "*") and now stuck with this error. – Sat Thiru May 14 '19 at 17:09

2 Answers2

1

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/react-transition-group@2.0.15

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

Sat Thiru
  • 722
  • 1
  • 7
  • 17
0

I had the same problem, and there is an eerily similar issue reported just now for a @types/recompose module. As a temporary fix I uninstalled @types/react-transition-group and added a types/react-transition-group.d.ts file at the root of my project with the following:

declare module 'react-transition-group' {
    export const CSSTransitionGroup: any
}

At least then you aren't changing stuff from the node_modules folder. I'm using v1 of react-transition-group so your placeholder definition might look a little different. Of course you'll loose all type-hinting you don't provide yourself, so it might be and idea to give the GitHub repo a heads up as well so they can provide a fix, should the recompose issue not be relevant.

Tomm Huth
  • 175
  • 1
  • 9
  • I have run into the same issue and forked the DefinatelyTyped repo (source of @types/react-transition-group) and fixed as above. Problem is if I try to run their tests it fails with "This is the default value for this type parameter, so it can be omitted." So it's "damned if I do, damned if I dont." lol – guru_florida Apr 23 '19 at 01:38