TypeScript errors after installing 7.2.3 relating to @types/react-redux now being a "dependency"
See original GitHub issueAfter installing 7.2.3, our build failed due to TS error pertaining to duplicate declarations. (see below). We’ve seen this before and I tracked it down to the release of react-redux last night. We initially had @types/react-redux
in our package.json, which has since been removed, but the errors were still present. Due of the sub dependency of @types/react
being 17.0.3 in react-redux,
and our explicit @types/react
being 16.14.5
, @types/react
is not deduped. If we upgrade to 17.0.3
as well, then we no longer get errors, but this is forcing us to have a miss-match between our react version and the @types/react
version.
It’s questionable as to whether 7.2.3 supports react 16 because of this. Maybe this is a known issue and the action described above is what you’d expect?
TS Errors for reference for others:
node_modules/@types/react-redux/node_modules/@types/react/index.d.ts:2976:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
2976 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/react/index.d.ts:2977:14
2977 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
~~~~~~~~~~~~~~~~~~~~~~~~
'LibraryManagedAttributes' was also declared here.
node_modules/@types/react-redux/node_modules/@types/react/index.d.ts:2987:13 - error TS2717: Subsequent property declarations must have the same type.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:14 (7 by maintainers)
@markerikson From what I can see, the latest 16.x and 17.x of the @types/react and @types/react-redux are compatible (i.e no TS errors) and similarly, react 16 and and 7.2.3 react-redux are ok too (besides the TS errors). Our main blocker for upgrading to react 17 is enzyme not being compatible, so for now, we’ve gone back to 7.2.2.
Thing is, we don’t maintain the React-Redux types ourselves. The community has always done so. That’s why they lived in DefinitelyTyped instead of in this repo.
We did add myself and Lenz to the “list of maintainers for these types” in DTS recently because someone else had filed a PR that marked one of the types as
deprecated
incorrectly without ever consulting us about the intended usage, so we want to be notified in case anyone ever tries to make unwanted changes like that in the future. But, we haven’t actually worked on the types ourselves.When we get around to working on React-Redux v8, we’ll rewrite the library in TS. Until then, the types can stay where they are.