1

I have typescript error with Switch and Route from react-router-dom and I don't know why they appear. Probably it's because of libraries versions incompatibility, but I did't find information about it.

Switch type error

Route type error

Libraries versions:

  • react: 17.0.1
  • @types/react: 17.0.1
  • react-router-dom: 5.2.0
  • @types/react-router-dom: 5.3.1
  • typescript: 4.5.5

UPD. I updated @types/react-dom library, because it has old version and added @types/react-router library and types errors disappeared.

1
  • what is the error ? Commented Feb 26, 2022 at 16:34

1 Answer 1

0

I had an issue with a similar scenario, the error message was related to React Router typings, and in the path route you could finde something like /react-router/ts4.6/index.dts

It seems that the typings have been updated to use a more modern version of TypeScript, in my case I had installed version 3.9, so I just upgraded to the latest TypeScript stable version and the errors went away (of course due to the upgrade got another minor errors in my app that I had to fix).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.