@types/enxyme package and had problems.Definitions by: in index.d.ts) so they can respond.Using:
I get several compiler errors like this in enzyme's .d.ts file:
node_modules/@types/enzyme/index.d.ts:60:20 - error TS2707: Generic type 'ReactElement
' requires between 1 and 2 type arguments.
60 contains(node: ReactElement | ReactElement[] | string): boolean;
This problem seems to be new to @types/enzyme 3.1.18. If I revert to version 3.1.17, then ReactElement<any> is used throughout the type definitions, which compiles successfully.
@UselessPickles it appears that this is due to the alphabetical sequence of publishing. The enzyme types are looking for a version of react types that doesn't exist yet. You can watch the bot publish here -> https://github.com/DefinitelyTyped/DefinitelyTyped/pull/32990
@UselessPickles It appears that @types/react 16.8.2 has been published. I'm betting your issue no longer repro's and this can be closed.
Looks like I just picked the wrong time to upgrade all my NPM dependencies :)
I now have @types/react 16.8.3 and @types/enzyme 3.1.18 and can confirm the problem is solved. Thanks!
i am facing the below issue
$ react-scripts build
Creating an optimized production build...
Failed to compile.
C:/Pavans/BA-SPOG/WS/ba-spog-dashboard/src/app/node_modules/@types/enzyme/index.d.ts
Type error: Generic type 'ReactElement
' requires 1 type argument(s). TS2314
59 | * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in.
60 | */
61 | contains(node: ReactElement | ReactElement[] | string): boolean;
| ^
62 |
63 | /**
64 | * Returns whether or not a given react element exists in the shallow render tree.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
and my dependencies are as follows:
"dependencies": {
"@scuf/common": "^0.28.0",
"@scuf/datatable": "^0.22.3",
"@types/dotenv": "^6.1.0",
"@types/ldclient-js": "^1.1.11",
"@types/react-redux": "^7.0.5",
"@types/react-router-dom": "^4.3.1",
"@types/react-test-renderer": "^16.8.1",
"@types/redux": "^3.6.0",
"axios": "^0.18.0",
"dotenv": "^6.2.0",
"ldclient-node": "^5.6.2",
"mobx": "^4.1.1",
"mobx-react": "^5.0.0",
"mobx-router5": "^4.2.3",
"mobx-utils": "^4.0.0",
"moment": "^2.22.2",
"node-sass": "^4.9.3",
"query-string": "^6.4.0",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-mobx-router5": "^6.1.1",
"react-redux": "^6.0.1",
"react-router-dom": "^5.0.0",
"react-scripts": "^2.1.1",
"react-test-renderer": "^16.8.4",
"redux": "^4.0.1",
"router5": "^6.5.1"
},
"devDependencies": {
"@types/enzyme": "^3.1.18",
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/jest": "^23.3.9",
"@types/node": "^10.12.7",
"@types/react": "^16.8.3",
"@types/react-dom": "^16.0.9",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.11.2",
"jest-fetch-mock": "^1.6.6",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"tslint": "^5.11.0",
"tslint-react": "^3.6.0",
"typescript": "^3.1.1"
}
Thanks in advance
@pavanjava I believe ReactElement requires a type argument: React.ReactElement<T>. Are you looking for React.ReactNode?
Most helpful comment
Looks like I just picked the wrong time to upgrade all my NPM dependencies :)
I now have
@types/react 16.8.3and@types/enzyme 3.1.18and can confirm the problem is solved. Thanks!