EDIT
Why is this issue extremely painful? So far while I debugged/tested my Web App I've just edited the .ts in VS IDE, saved, then reloaded the page and tested the changes. Now I have to build. However build is not enabled when debug session is running in the VS IDE. So now I have to do a complete roundtrip: edit .ts -> save -> stop debugging -> build -> launch debug. Again, this is extremely painful. END EDIT
I've unchecked / saved / checked the setting in TypeScript Build tab in my project setting.
The appropriate <PropertyGroup>
was generated and saved to my .csproj file.
(note without changing any TypeScript Build setting, this <PropertyGroup>
is not there (when using an existing project what was previously created with VS 2013), and the build defaults are not the same as the defaults on the IDE UI so you are misleaded.)
Anyway after this change / save activity my .csproj file is in sync with the IDE UI here it is:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptRemoveComments>True</TypeScriptRemoveComments>
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>None</TypeScriptModuleKind>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptSourceMap>True</TypeScriptSourceMap>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />
</PropertyGroup>
As it shows the Compile on Save is definitely enabled. Still the .js file only generated during build and not when the .ts file was saved.
Btw: Regarding that TypeScript compile is an msbuild task in VS 2015 implementation it is interesting how could this Compile on save setting even work...
More diagnostics: Interestingly in case if I delete the whole propertygroup then it actually compiles on save. (The UI remains the same, and the .map files are not generated on the save, only on build.)
TypeScript is compiled to JavaScript. Therefore, TS can be used anywhere JS could be used: both the frontend and the backend. JavaScript is the most popular language to implement scripting for the frontend of apps and web pages.
Typescript is a superset of javascript but it is a strongly typed, object-oriented programming language. Typescript file does not run directly on the browser as javascript run, we have to compile the typescript file to the javascript then it will work as usual.
Directory dist/ is where the output of the compiler is stored. The TypeScript compiler compiles a TypeScript file such as ts/src/main. ts to a JavaScript file dist/src/main.
For example, for TypeScript 3.6. 0, you would use npm install --save-dev [email protected] . To preview the next version of TypeScript, run npm install --save-dev typescript@next .
did you look for the "Tools" menu < options... < Typescript < project and check the "compile on save" checkbox ?
I got it working finally by adding "compileOnSave": true
to my tsconfig.json
.
So you tsconfig should look like :
{
"compilerOptions": {
....
},
"compileOnSave": true
}
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