TypeScript: Typescript compile on save setting in Visual studio is not honored
Repro steps: Edit a typescript file.
Expected behavior: If Tools -> Text Editor -> Typescript -> Project -> General If Compile on Save option unchecked equivalent js file should not be generated at the current location.
Current behavior: Generating a js file.
Earlier versions of ntvs had this in the project file for the behavior
<EnableTypeScript>true</EnableTypeScript>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
<ToolsVersionPromptShown>1.7</ToolsVersionPromptShown>
Which was automatically generating the js file.
When I open a nodejs solution, I currently see it’s automatically edited. But I don’t see above setting changes getting added in the edit. I am currently not sure where it is getting controlled from.
Issue redirected from https://github.com/Microsoft/nodejstools/issues/832
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 21 (7 by maintainers)
If you are using a tsconfig, set
"compileOnSave": true
in it. see http://www.typescriptlang.org/docs/handbook/tsconfig.json.html#compileonsaveIf you are not using a tsconfig.json file, then the project property pages should would be the place to set CompileOnSave.
If you do not have a project file, i.e. open a ts file and start editing, then use Tools -> Text Editor -> Typescript -> Project -> General to turn compile on save on.
hope that helps.
You need to add
{ "compileOnSave": true }
to your tsconfig.json file. However, it doesn’t seem to always follow it, or there are hidden errors… not sure; it’s very flaky.If I can come up with a repro I’ll make sure to post it – unfortunately it seems rather random. Sometimes right-clicking on the project and choosing “rebuild” works when just saving doesn’t. Just “build” doesn’t seem to work…
@rkavalap the fix is in https://github.com/rkavalap/NightWatchTest/pull/2/commits/a3066a44740e7a615f56026e9ee52ad1527b3939
The better fix is to add a tsconfig.json to your project.
you can find the full documentation for the properties in http://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html