Tom
Tom

Reputation: 2611

Visual Studio Code Typescript not compiling on save

I'm struggling to get Visual Studio Code to compile my TypeScript to Javascript. I've been successfully working with TS in Visual Studio 2017, however I thought I'd give VS Code a try.

I've got the watch task running, the last line in the terminal output is:

15:57:49 - Compilation complete. Watching for file changes.

However, when I save a ts file, nothing is happening. Again, in VS2017, it compiles on save fine.

There are areas of the project that produce a fair few TS errors - these are areas that have been written by others and are out of the scope of my project. I'm wondering if these errors would be stopping the compilation? Or should it still compile on a file-by-file basis?

ts.config

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
  },
  "compileOnSave": true,
  "exclude": [
    "node_modules",
    "wwwroot",
    "typings/ckeditor/ckeditor.d.ts",
    "typings/ckeditor/index.d.ts",
    "typings/lodash/lodash.d.ts"
  ],
  "include": [
    "**/*.ts"
  ] 
}

Versions

VSCode 1.17.2

Typescript 2.5.3

Upvotes: 1

Views: 4718

Answers (1)

Aleksey L.
Aleksey L.

Reputation: 37938

"noEmitOnError": true compiler option prevents javascript generation in case typescript errors found.

More on compiler options here

Upvotes: 2

Related Questions