Typescript compile on save does not work when tsconfig.json is in the project

I cannot get visual studio to run typescript compilation in js when saving.

enter image description here

I have xproj (asp.net core with network card) TypeScript 2.0.3 tools for updating Visual Studio 2015 3.

I tried to include "watch" : true in tsconfig.json, but it says the current host is not supported.

I went to Tools> Options> Text Editor> typescript> Project and turned on "automatically compile typescript files that are not part of the project"

enter image description here

However, changes to .ts files will only be displayed in .js files only at compile time, but only when there are changes in the c_rd-side files that need to be compiled.

EDIT: I found out that the mere existence of tsconfig.json in the project directory will prevent the compilation from being saved even if the configuration file is empty.

Could this be fixed somehow now?

This is the contents of my tsconfig.json:

 { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "diagnostics": true }, "include": [ "**/*.ts" ], "exclude": [ "node_modules" ] } 

EDIT 2 : I also tried:

 { "compileOnSave": true, "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false, "diagnostics": true }, "filesGlob": [ "**/*.ts" ], "exclude": [ "node_modules" ] } 

and did nothing.

+6
source share
2 answers

I uninstalled Visual Studio 2015 and Typescript 2.0.3. Then I reinstalled Visual Studio 2015. After opening my solution and checking Typescript 1.8.3, I installed Typescript 2.0.3 and added "compileOnSave" before "compilerOptions". Since then it works for me. After adding this option, you must restart Visual Studio.

 { "compileOnSave": true, "compilerOptions": { ... } 
+6
source

Adding "compileOnSave":true to tsconfig.json should do the trick:

 { "compileOnSave": true, "compilerOptions": { ... 
+2
source

All Articles