I can't make visual studio to run typescript compilation to js when I save.
I have an xproj (asp.net core with net framework) TypeScript 2.0.3 tools for Visual studio 2015 update 3.
I have tried to enable "watch" : true
in tsconfig.json but it says that current host is not supported.
I went to Tools > Options > Text Editor > TypeScript > Project and enabled "automatically compile TypeScript files which are not part of project"
Still, changes in .ts files will be reflected in .js files only during compilation, but only when there are changes in c# sever-side files that has to be compiled.
EDIT: I have figured out that simple existance of tsconfig.json in the project directory will prevent compilation on save even if the config file is empty.
Can that be fixed somehow currently?
This is the content 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 it didn't do anything.
The presence of a tsconfig. json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig. json file specifies the root files and the compiler options required to compile the project.
Running tsc locally will compile the closest project defined by a tsconfig. json , you can compile a set of TypeScript files by passing in a glob of files you want.
I uninstalled Visual Studio 2015 and Typescript 2.0.3. Then I reinstalled Visual Studio 2015. After opening my solution and checked Typescript 1.8.3, I installed Typescript 2.0.3 and added "compileOnSave" before "compilerOptions". Since then it works for me. You need to restart Visual Studio after adding this option.
{
"compileOnSave": true,
"compilerOptions": {
...
}
Adding "compileOnSave":true
to tsconfig.json should do the trick:
{
"compileOnSave": true,
"compilerOptions": {
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With