WebStorm seemingly having trouble reading tsconfig.json

WebStorm doesn't seem to be reading my tsconfig.json and I can't figure out what's going on.

For example, in one file I'm getting this error:

TS1259: Module '"./node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag

But as you can see in the config file, esModuleInterop is defined.

Another big issue is it doesn't seem to be resolving path aliases correctly:

TS2307: Cannot find module '@components/Tabs/styled' or its corresponding type declarations.

./tsconfig.json:

{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@app/*": ["./*"],
"@components/*": ["components/*"],
"@graphql/*": ["graphql/*"]
},
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "es2019"],
"moduleResolution": "node",
"allowJs": true,
"noEmit": true,
"strict": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"strictNullChecks": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": ["node_modules"],
"files": ["custom.d.ts"],
"include": ["next-env.d.ts"]
}

WebStorm 2021.1.2

TypeScript 4.0.5

Node 15.14.0

4 comments
Comment actions Permalink

How many tsconfig.*.json files do you have in your project? WebStorm built-in compiler service uses the nearest tsconfig.json current file is included in for compiling, traversing the folders hierarchy from current folder up to the IDE project root. Your tsconfig.json only includes 2 files - custom.d.ts and next-env.d.ts, note the "files" and "include" sections; so it's not used for other files processing, they are processed either using the other configs or using the default compiler settings

1
Comment actions Permalink

Hi Elena Pogorelova, we just have the one tsconfig.json in the project root. So adding "./**/*" to include should probably fix it?

0
Comment actions Permalink

You c an just remove both the "files" and "include" sections to have all .ts files included

1
Comment actions Permalink

Elena Pogorelova, great, thanks so much!

0

Please sign in to leave a comment.