I had the exact same issue of "Cannot Resolve Symbol" for most of the imports in Intellij, when I upgraded to the react-router-dom:6.0.2
.
As @DLH stated, the Jetbrains Product was reading the type file for the package from <system directory>/jetbrains/intellij/javascript/typings
rather than from the node_modules
folder of the project.
As said by Oksana Chumak from Jetbrains:
The IDE downloads typings for some popular libraries to its configuration folder and uses them to enhance code completion.
Solution:
Inside the jetbrains product, press shift two times to open the search everywhere window, search for registry and open the first result.
In the registry, look for typescript.external.type.defintions.packages key and in the value of that field, only remove the react-router-dom field from the values.
Also Go to File -> Invalidate Caches -> select "Clear file system cache and Local History" -> click "Invalidate and Restart"
Now, the jetbrains product will read the type file from node_modules
of project, rather than reading it from its internal typings folder
. In the future, It will also not try to download and use the intellij react-router-dom typings for other projects.
Credits: Props to @Mir-Ismaili and @unfestive chicken for helping out with the third step.