<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>TypeScript</title><link>http://timlabonne.com:80/typescript</link><description>TypeScript</description><item><title>Getting Compile-on-Save to work for TypeScript in VS2012</title><link>http://timlabonne.com:80/2013/07/getting-compile-on-save-to-work-for-typescript-in-vs2012/</link><description>&lt;p&gt;I’m poking around with TypeScript and the word on the street was that a recent addition to the plugin for VS2012 (v. 0.8.x) added the ability to do compilation from TypeScript to JavaScript when saving.&amp;nbsp; I discovered it doesn’t actually work quite right out of the box.&amp;nbsp; There are two things you need to do:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Enable compile on save in the Tools –&amp;gt; Options menu.&lt;/li&gt; &lt;li&gt;Add a &amp;lt;PropertyGroup&amp;gt; to your .csproj file to configure the TypeScript compiler.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To enable compile-on-save, do the following:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Navigate to Tools –&amp;gt; Options.&lt;/li&gt; &lt;li&gt;On the left side, expand Text Editor and find TypeScript, and then the Project sub-node.&lt;/li&gt; &lt;li&gt;Check the “Automatically compile TypeScript files which are part of a project”&lt;/li&gt; &lt;li&gt;Click OK to save changes.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Next, you need to update your project that you are using to contain the appropriate properties to configure the build target for the TypeScript compiler.&amp;nbsp; Add this XML to your .csproj (first, unload the project and then edit the .csproj file manually):&lt;/p&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;PropertyGroup Condition="'$(Configuration)' == 'Debug'"&amp;gt;
  &amp;lt;TypeScriptTarget&amp;gt;ES5&amp;lt;/TypeScriptTarget&amp;gt;
  &amp;lt;TypeScriptIncludeComments&amp;gt;true&amp;lt;/TypeScriptIncludeComments&amp;gt;
  &amp;lt;TypeScriptSourceMap&amp;gt;true&amp;lt;/TypeScriptSourceMap&amp;gt;
  &amp;lt;TypeScriptModuleKind&amp;gt;amd&amp;lt;/TypeScriptModuleKind&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;
&amp;lt;PropertyGroup Condition="'$(Configuration)' == 'Release'"&amp;gt;
  &amp;lt;TypeScriptTarget&amp;gt;ES5&amp;lt;/TypeScriptTarget&amp;gt;
  &amp;lt;TypeScriptIncludeComments&amp;gt;false&amp;lt;/TypeScriptIncludeComments&amp;gt;
  &amp;lt;TypeScriptSourceMap&amp;gt;false&amp;lt;/TypeScriptSourceMap&amp;gt;
  &amp;lt;TypeScriptModuleKind&amp;gt;amd&amp;lt;/TypeScriptModuleKind&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Notice that you can set various compiler options here that you normally set as a command-line parameter when using the tsc compiler program.&amp;nbsp; In this case, I added the &amp;lt;TypeScriptModuleKind&amp;gt; element which tells the compiler how to generate the module requiring code.&amp;nbsp; Here, I’ve set mine up to use AMD rather than CommonJS (which is the default).&amp;nbsp; My Target is also “ES5” so it will target ECMAScript 5 rather than the default ECMAScript 3.&amp;nbsp; &lt;/p&gt;</description><pubDate>Fri, 19 Jul 2013 15:31:00 GMT</pubDate><guid isPermaLink="true">http://timlabonne.com:80/2013/07/getting-compile-on-save-to-work-for-typescript-in-vs2012/</guid></item></channel></rss>