'TypeScript type definitions IntelliSense errors

With Visual Studio 2022, I have a lot of IntelliSense errors in the error list window about type definitions of the node_modules folder.
In my tsconfig.json file, I excluded the node_modules folder : "exclude": ["node_modules"].
In my csproj, I added the line <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>.
But nothing works, I didn't succeed in removing these errors.

enter image description here



Solution 1:[1]

After lots of trial and error, I've gotten "exclude": ["./node_modules/**/*.*"] to successfully ignore node_modules. It didn't take effect until I restarted Visual Studio.

Solution 2:[2]

It will depend on your tsconfig - can you share your setup? Will want to exclude your dist file as well as your node_modules (and if you want tests/spec files).

"exclude": ["node_modules", "**/*.spec.ts", "dist"]

Webpack has not exported member compilation was the error i saw first - what are you importing with that? Docs here for webpack and typescript.

Wondering if your types are discoverable, could try adding below to tsconfig

"typeRoots": [
   "./node_modules/@types"
]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jacob Stamm
Solution 2 Jeremy