The "Compile on save" feature isn't working for me after upgrading to Visual Studio 2015. When I make a change to a .ts
file in my project and save, the status bar at the bottom of the IDE says Output(s) generated successfully
, but the generated .js
file doesn't change.
Here's what I've tried:
adding the following to the root
<Project>
element in my.csproj
:<PropertyGroup> <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled> </PropertyGroup>
checking and unchecking the "Automatically compile TypeScript files which are not part of a project" option in
Tools -> Options -> TypeScript -> Project
:double checking to make sure "Compile on save" is checked in my project's TypeScript Build properties:
What am I missing?
As a side note, the TypeScript compilation step does work as expected when triggered by a regular build.
Solution:
For me, and I am quite sure this is also the case for others, this was due to a mistake in the tsconfig.json.
You need to add "compileOnSave": true. But in the global section not inside compilerOptions.
Best regards,
Anders Both Basechat.
This issue seems to have been resolved with the most recent update to the
TypeScript Language Services
extension.See this answer for instructions on how to apply this update.
With typescript 2 you have to delete "outDir": from your tsconfig. Fix the bug for me in visual studio.
The
"compileOnSave": true,
wasn't working for me. I finally figured out that Visual Studio doesn't honor the"compileOnSave": true,
value if it is defined in another.json
file that you're extending. It has to be in the root in order for it to work.I stumbled upon this problem today: I fixed that by using the new
"watch":true
compiler option, also available through JSON in most recent TypeScript versions:After doing that, I had to solve another issue related to the following error that appeared in the output window:
It turned out that my system was using an outdated version of TypeScript (1.0.x), despite I was sure I had a newer one that came with the Visual Studio 2015 Update 1 (1.7). If you run into this problem, you can easily check your tsc version by typing
tsc -v
from a command-prompt.If it says
1.0.x
or anything < 1.7, it's probably due to the fact that you have some old references in your PATH environment variable. Be sure you have 1.7 or later installed by checking inside your Microsoft SDKs folder, which is the one used by Visual Studio to install the TypeScript packages as they get updated:If not, update accordingly. Open CPanel > System > Advanced > Environment Variables, select System Variables and click on Edit; browse through the list looking for any reference to the TypeScript folder, change one of them to make it point to your TypeScript most recent installed version (
1.7
or above) and delete any other dupes. See also screenshot below:For additional details, read this post on my blog.
For me it was this option in
tsconfig.json
:Restart Visual Studio for this change to take effect.