Typescript - Installing with npm v4+ causes duplicate react types.
I'm Submitting a ...
[x] Bug report
[ ] Feature request
[ ] Support request
Steps to Reproduce
- Use
npm v4.x(I've tried with4.3.0and4.6.1) (not reproducible with3.10.10) - Have a
package.jsonthat has:
{
"scripts": {
"build": "tsc index.tsx"
},
"dependencies": {
"react-datetime": "2.9.0",
"react": "15.6.1",
"react-dom": "15.6.1",
"moment": "2.18.1"
},
"devDependencies": {
"@types/react": "15.6.1",
"typescript": "2.4.2"
}
}
Expected Results
My code to compile.
Actual Results
A bunch of errors about react types not matching due to react-datetime pulling in @types/[email protected]
Minimal Reproduction of the Problem
Using the package.json above, and the following index.tsx:
import * as React from 'react';
import * as Datetime from 'react-datetime';
npm inpm run build
You get a few pages of errors that look like this:
node_modules/@types/react/index.d.ts(3400,19): error TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement<any>' and 'ReactElement<any>'.
Named property 'type' of types 'ReactElement<any>' and 'ReactElement<any>' are not identical
Other Information (e.g. stacktraces, related issues, suggestions how to fix)
Works fine with npm v3 since v3 does not install a separate version of @types/react in /node_modules/react-datetime/node_modules/@types/react
I'm fairly certain (but in the process of verifying) that this is due to the PR which moved @types/react from devDependencies to dependencies.
I can confirm that this is indeed the cause.
@cwmacdon See my questions in #409.
Closing as PR #409 was merged.