I've got a web project in Visual Studio 2017 with a large TypeScript codebase. When I do a TypeScript build, I get no errors, and the resulting JavaScript is correct. However, my intellisense shows errors for any imports using a path based on the baseUrl
configured in my tsconfig.json.
For example:
When I change these to a relative path, the errors go away:
Other editors' code inspection doesn't seem to have a problem with the former. We've confirmed it working in VS Code and JetBrains Rider.
My tsconfig.json is as follows:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"strictNullChecks": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "amd",
"moduleResolution": "node",
"baseUrl": "./Content/ts"
},
"exclude": [
"node_modules"
],
"compileOnSave": true
}
I've tried as many different Visual Studio settings as I can find, but nothing seems to affect whether intellisense is able to find the modules. Again, the compiler itself has no issue finding them and building.
Update: Forgot to include that we also had the <TypeScriptBaseUrl>
property defined in the .csproj file, set to the same value that's present in our tsconfig.json. This causes the TS build within Visual Studio to succeed, but doesn't seem to affect Intellisense.
Turns out the tsconfig.json file needs to be included in the project to get Intellisense to be happy. Not sure why the <TypeScriptBaseUrl>
setting wasn't good enough. That's probably still a bug that needs to be reported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With