6

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.

enter image description here

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.)

1
  • I create a single output js-file in my typescript project. If I build, it still creates a js-file for each ts-file. If I compile on save, it output to a single js-file, correctly. Strange, buggy, time-consuming, and frustrating experience. Sometimes the ts-files get out of order, if I open _references.ts and saves inside that file, it follows the reference order and the js-output is correct again. I have not been able to find the "correct" way to compile multiple ts-file to a single js-file, yet - if there is one. Commented Aug 6, 2015 at 11:09

5 Answers 5

4

did you look for the "Tools" menu < options... < Typescript < project and check the "compile on save" checkbox ?

Sign up to request clarification or add additional context in comments.

6 Comments

I have no such option... It is just me?
nope, I don't have that option/category.. (@2015 Update 1)
The settings for Typescript exist under Tools -> Options -> Text Editor -> Typescript -> Project
This should be marked as the answer.... Tools -> Options -> Text Editor -> Typescript -> Project is the place to enable Auto compile on save
This is still not working. Now I am battling with the very same issue with VS 2017. Now I have that auto compile option, but is say "Automatically compile.... which are not part of project". And btw does not work.
|
3

I got it working finally by adding "compileOnSave": true to my tsconfig.json.

So you tsconfig should look like :

{
    "compilerOptions": {
         ....
    },
    "compileOnSave": true
}

Comments

2

Worked for me when i moved compileOnSave to before compilerOptions in the tsconfig file.

1 Comment

Indeed, this was my problem. I had compileOnSave below the options and wondered why it did not work. Thanks.
1

I had same problem, so I:

  1. followed citykid's advise,
  2. created .js.map file by myself,
  3. tried your guide - it started to work, however I
    • compared PropertyGroup section which was slightly different, thus I tested your's config and
  4. re-enabled debuggers from citykid's advise

... And it still works like charm.


It could be irrelevant but I have:

  • Visual Studio Pro 14.0.23107.0
  • Microsoft ASP.NET and Web Tools 14.0.60814.0
  • TypeScript for MS VS 1.6.3.0 (!)
  • Web Essentials 0.5.197 installed
  • Web Compiler 1.8.270 installed
  • Bundler & Minifier not installed
  • ReSharper 9.2 (?)

To test it, I recommend to:

  1. open .js.map,
  2. modify .ts by adding function - .js.map reloads,
  3. debug in IE,
  4. modify .ts by adding function - .js.map reloads,
  5. reload page and it should reflect changes in both debugger and browser.

Comments

1

For Visual Studio 2019:

Step 1 Tools > Options :

enter image description here

Step 2 In your tsconfig.json:

{
  "compileOnSave": true,    <---- insert before compilerOptions
  "compilerOptions": {
    "noImplicitAny": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "ESNext",
    "outDir": "./wwwroot/js"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.