Reputation: 28617
NB: I'm using TypeScript under Visual Studio 2010, so unfortunately using Web Essentials 2012 as a solution is not an option.
TypeScript 0.8.2 has added a feature to compile on save which I have enabled on my project by following the instructions on that page. The only additional change I have made to my project file is to add a
<TypeScriptModuleKind>amd</TypeScriptModuleKind>
property to each of the groups which tells TypeScript to build my files as AMD modules.
This works fine when the project is fully built, but when I save a single file and the auto-compilation triggers it does so without the module switch and the generated Javascript no longer works.
Is there anyway to force the compile on save feature to apply certain parameters to the tsc call?
Update:
A little more searching and I found this work item where someone else has the same issue. It was closed as can not reproduce, so can anybody out there confirm that it works for them and if I should take this quote:
The Compile on Save options specified in the project file...
To imply that there is some way of setting the options for Compile on Save separately to the debug and release options defined on the wiki page I linked to above?
Upvotes: 3
Views: 476
Reputation: 9509
This issue has been fixed in subsequent releases; also issues related to the ability to specify an output file for Compile-on-Save. if you are using Visual Studio 2012 or Visual Studio 2013 consider upgrading to a later build.
You can try out the 0.9.5 beta from: https://typescript.codeplex.com/wikipage?title=TypeScript%200.9.5%20beta
Upvotes: 1
Reputation: 2168
You can define a custom target in your .csproj file - or use the one defined in Microsoft.TypeScript.targets - and then associate a custom tool to one your .ts files.
For this just set the "Custom Tool" property of the file to **MSBuild:***NameOfYourMSBuildTarget*
The target will be called every time the file(s) associated with the custom tool is saved.
See my answer to this question for more details on this approach.
Upvotes: 0