1
votes

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

1
do u face with an error?Jimmy
@Salman Other than the linting errors from the other projects, nope.Tom
so, how do u know they do not stop transpiling process?Jimmy
@Salman I don't know if they're stopping them, that's part of my question :) However it seems strange that VS 2017 compiles them fine.Tom
You defined "noEmitOnError": true so if you have typescript errors js won't be generatedAleksey L.

1 Answers

2
votes

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

More on compiler options here