react-hooks-testing-library: Duplicated identifier Errors with TypeScript
react-hooks-testing-libraryversion: 1.0.4react-test-rendererversion: 16.8.6reactversion: 16.8.17@types/reactversion: 16.8.17typescriptversion: 3.3.3333nodeversion: 11.9.0npmversion: 6.7.0
Relevant code or config:
-
What you did:
I installed the latest Version of react-hooks-testing-library and got after a typecheck the following error.
What happened:
node_modules/@testing-library/react-hooks/node_modules/@types/react/index.d.ts:2817:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
2817 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/react/index.d.ts:2816:14
2816 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
'LibraryManagedAttributes' was also declared here.
node_modules/@testing-library/react-hooks/node_modules/@types/react/index.d.ts:2881:13 - error TS2717: Subsequent property declarations must have the same type. Property 'iframe' must be of type 'DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>', but here has type 'DetailedHTMLProps<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>'.
2881 iframe: React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
~~~~~~
node_modules/@types/react/index.d.ts:2816:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
2816 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@testing-library/react-hooks/node_modules/@types/react/index.d.ts:2817:14
2817 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
'LibraryManagedAttributes' was also declared here.
Reproduction:
Problem description:
The issue is that I use the @types/react: 16.8.17 while this library uses @types/react: 16.8.22 which results in 2 different installed @types/react versions. After updating to the latest @types/react the problem was solved.
Suggested solution:
There should be any typescript dependency installen when I install this package.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 25 (11 by maintainers)
Commits related to this issue
- Automatically wrap waitForNextUpdate in act. Fixes #14, #110 — committed to testing-library/react-hooks-testing-library by mpeyper 5 years ago
- 0.3.1 * Fixing build caused by @testing-library/react-hooks https://github.com/testing-library/react-hooks-testing-library/issues/110 — committed to atomicpages/react-accessible-shuttle by atomicpages 5 years ago
I think the problem should be solve by moving the
@typesdefinitions from thedependenciesto thedevDependenciesin thepackage.json.See also: https://docs.npmjs.com/files/package.json#devdependencies
For anyone following this issue, I’m thinking we’re going to follow the path of some other testing-library packages and move the types to DefinitelyTyped and make them a dependency here.
To be honest, I don’t know how it is any different from what we’re currently doing (other than moving the dependencies in a layer) or that it will make this situation any better, but I’m not seeing any complaints on the approach in the other package repos.
Happy for anyone to take the reigns on either the DefinatelyTyped side or the relevant changes here.
@mpeyper same issue.
Using: @testing-library/react-hooks@2.0.1
Maybe add it as an optional dependency?