Steve Dolan Steve Dolan - 1 month ago 22
TypeScript Question

Angular 2 .ts file not transpiling to .js on save in Visual Studio 2015 ASP.NET Core project

If I make a change to app.component.ts and save the file, the change won't appear in app.component.js until I build the project manually.

My goal is to have Angular 2 code changes reflected in the browser after I save. I shouldn't have to do a build every time.

Here is my tsconfig.json:

{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}

Answer

You're missing "compileOnSave": true. The TypeScript documentation says it only works with Visual Studio 2015 and with the Atom TypeScript plugin. It also requires TypeScript 1.8.4 or higher.

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
Comments