question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript errors after installing 7.2.3 relating to @types/react-redux now being a "dependency"

See original GitHub issue

After 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:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
marchaoscommented, Mar 23, 2021

@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.

1reaction
markeriksoncommented, May 6, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Im have a Typescript Problem which already asked ...
I can see there are problems in your dist folder, try: rm -rf node_modules/ and npm install . You will have to make...
Read more >
Common TypeScript module problems and how to solve them
A firm understanding of TypeScript modules system. Problem 1: Irregular location of dependencies. On a normal occasion, the node-modules ...
Read more >
Third-party software dependencies | Elastic Cloud Enterprise ...
Library Version Optional/Required Packaged akka‑actor_2.13 2.6.18 Required Yes akka‑http‑core_2.13 10.2.7 Required Yes akka‑http‑json4s_2.13 1.27.0 Required Yes
Read more >
[VS 2022] Javascript Content Files Project errors when using ...
I have installed dotnet 6.0.100 using Visual Studio 2022. Ran the commands to upgrade from angular 12 to angular 13 (which has a...
Read more >
react-redux: Versions - Openbase
If you are using Typescript, React-Redux is now written in TS and includes its own types. You should remove any dependencies on @types/react-redux...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found