Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode ignoring tsconfig.json and compiling single file generating incorrect errors?

I recently updated typescript, angular, and basically every library in my project. Before I did this update the problem didn't exist. From the command line I've ensured that my code builds without errors or warnings. However, when I open the project in Visual Studio Code and make changes to a file it starts highlighting stuff as errors.

It highlights my imports at the top saying cannot find module 'angular2/core'. and my @Components, @Outputs and @Inputs say Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning. It's also highlighting some of my Window properties that I have declared in a .d.ts file.

Yet this is my tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "inlineSourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "pretty": true
  },
  "exclude": [ "node_modules" ]
}

It seems that when I change a file VSCode is building the single file I just changed without using my tsconfig. If I build from the command line I get zero errors or warnings. If I press Ctrl+Shift+B to run the build inside VSCode then all the errors go away. Here's my tasks.json:

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "showOutput": "silent",
    "args": ["-p", "."],
    "problemMatcher": "$tsc"
}

How can I have VSCode look for errors and warnings using the entire project and not just the one file?

VSCode 0.10.8 typescript 1.8.7 Linux Mint 17.3 x64

like image 238
Corey Ogburn Avatar asked Jul 22 '26 23:07

Corey Ogburn


1 Answers

Turns out that VSCode comes with it's own instance of typescript and by updating I surpassed the version that's built in.

I was notified on github that you can specify which typescript to use by adding this to your User or Workspace settings:

"typescript.tsdk": "node_modules/typescript/lib/"

This has fixed my issues.

like image 61
Corey Ogburn Avatar answered Jul 25 '26 14:07

Corey Ogburn