I'm getting compile errors on many of my files. One issue seems to be that running my package.json
script: "react-scripts start" causes errors where I have two files in the same location with similar names.
For example when I have two files in the same location:
src\Context\GlobalContext\globalContext.ts
src\Context\GlobalContext\GlobalContext.tsx
And I try to import the GlobalContext.tsx
file, the compiler seems to be ignoring my GlobalContext.tsx
file and looking in globalContext.ts
.
Compiled with problems:X
ERROR in ./src/App.tsx 14:0-66
Module not found: Error: Cannot find file: 'GlobalContext.ts' does not match the corresponding name on disk: '.\src\Context\GlobalContext\globalContext.ts'.
...
src\App.tsx
Line 9:27: Casing of ./Context/GlobalContext/GlobalContext does not match the underlying filesystem import/no-unresolved
Line 10:25: Casing of ./Context/UserContext/UserContext does not match the underlying filesystem import/no-unresolved
It seems to work both ways though. This error suggests that the compiler is looking at a SearchContext.tsx
file when it should be looking at a searchContext.ts
file. The compiler seems to be ignoring the 'x' in the .tsx
and getting very confused:
TS1149: File name 'C:/../src/Context/SearchContext/searchContext.ts'
differs from already included file name
'C:/.../src/Context/SearchContext/SearchContext.ts'
only in casing.
This has never been a problem on Linux, and wasn't previously a problem on my Windows OS until today. I also appear to be having similar issues with my Node/Express server. I installed ts-node
I have tried:
- Reloading my VS Code
- Restarting my machine
- Toggling my
tsconfig.ts
compilerOptions
:"forceConsistentCasingInFileNames": false
- Clearing my VS Code cache (all above solutions from this thread)
- Restart the typescript server: opening the Command Palette (Ctrl+Shift+P) --> Select
Typescript: Restart TS
- Removing my VS code workspace (as per this suggestion)
- Renaming files fixes the issue. For example, changing
GlobalContext.tsx
toGlobalContextProvider.tsx
in both the import statement and the file name prevents the error.