Definitelytyped: [recompose] Generic type 'ReactElement<P>' requires 1 type argument(s)

Created on 14 Feb 2019  路  12Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

  • [x] I tried using the @types/recompose package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @iskandersierra (and many others, will not mention them all to reduce spam)


With the latest published version of @types/recompose I get the following error while building:

../../node_modules/@types/recompose/index.d.ts:338:8 - error TS2314: Generic type 'ReactElement<P>' requires 1 type argument(s).

338     ): React.ReactElement;

Most helpful comment

@ffflorian Hi !
You have to use the last version of @types/react

All 12 comments

@ffflorian Hi !
You have to use the last version of @types/react

Thank you for this solution
You have to use the last version of @types/react

Thank you. Updating@types/react worked for me, too.

@ffflorian Can we close this issue ?

@types/react version 16.8.3
@types/react-dom version 16.8.2
typescript version 3.3.3
still has the problem

@AlvinYuXT With the recompose library ?

If you have @types/react: 16.8.3, you should have

interface ReactElement<P = any, T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>> {
        type: T;
        props: P;
        key: Key | null;
    }

Line 86

Upgrading @types/react to 16.8.3 fixed it for me, too. Thanks!

@VincentLanglet I'm sorry it's not with recompose.
I find the reason why it's still wrong when I update @types/react. There is something wrong with my yarn.lock file

I discovered that my @types/react had been implicitly added as a sub-dependency of something else and was an older version. By making it explicit in package.json solved this for me. Try:

npm i @types/react --save-dev

and see if that solves it for you. Hope this helps someone.

@VincentLanglet I'm sorry it's not with recompose.
I find the reason why it's still wrong when I update @types/react. There is something wrong with my yarn.lock file

I manually removed "@types/react@*" entries from yarn.lock and did a new yarn install which solved the problem for me.

Project:
@types/react version 16.8.3
@types/react-dom version 16.8.2
typescript version 3.3.3

To fix hoisting, instead of yarn deduplicate, you could also put a temporary resolution entry in your package with the version you want to fix the lock file. In other words:
yarn why @types/react
...to list all versions and see if you have a problem with this package and why
edit your package.json to put a resolution line, something like:

"resolutions": {
        "@types/react": "16.8.3"
}

then run yarn install
(then check it out with yarn why again to see that it is all hoisted into one)
Check if all goes well with your build then remove the resolution entry (since the lock file contains what you wanted now).

Using version 16.8.3 fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings