3

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Like it's suggested, I'd prefer to not check in stuff in the node_modules folder. So what do you do if you have typescript installed globally? Specifying path to c://[user] is also a bad options since other people on the team gonna have different user names.
Don't check in your vscode settings file. Each dev should have their own.
Each developer solves the issue by putting the line in their own Workspace/User settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.