Pages

Sunday, December 22, 2013

Visual Studio TypeScript Defaults to ES5

TypeScript has jump the gun. ES5 as the default? I'm still working with clients on <= IE9.

Additionally in Visual Studio 2013, Web Essentials has stopped supporting TypeScript. Now changing between ES3 and ES5 isn’t easy as selecting tools > options > Web Essentials and changing to ES3/5.

However I needed the default to be ES3. Looking for an answer, I discovered TypeScript in Visual Studio 2012 defaulted to ES3, and there were a lot of question how to default to ES5. I reversed engineered their answer having TypeScript in Visual Studio 2012 defaulting to ES5.

Opening up the application’s program file (myProj.csproj) and appending, the code below, near the top of the project file, solved my issue. Now within Visual Studio 2013, TypeScript defualts to ES3.

   1: <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
   2:     <TypeScriptTarget>ES3</TypeScriptTarget>
   3:     <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
   4:     <TypeScriptSourceMap>true</TypeScriptSourceMap>
   5:     <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
   6:   </PropertyGroup>
   7:   <PropertyGroup Condition="'$(Configuration)' == 'Release'">
   8:     <TypeScriptTarget>ES3</TypeScriptTarget>
   9:     <TypeScriptIncludeComments>false</TypeScriptIncludeComments>
  10:     <TypeScriptSourceMap>false</TypeScriptSourceMap>
  11:     <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
  12:   </PropertyGroup>
Because Web Essentials  is no longer supported in Visual Studio 2013, the screen isn’t split with the TypeScript file on the left and JavaScript on the right, This isn’t an issue for me.

Now after saving the TypeScript file, a hidden JavaScript file is still created, and if I want the same Web Essentials experience, I vertically split my window with my TypeScript file on the left and Javascript is placed on the right.

Capture


This post is for the purpose of my notes only.

“I invented nothing new. I simply assembled the discoveries of other men behind whom were centuries of work. Had I worked fifty or ten or even five years before, I would have failed. So it is with every new thing. Progress happens when all the factors that make for it are ready and then it is inevitable. To teach that a comparatively few men are responsible for the greatest forward steps of mankind is the worst sort of nonsense.”
Henry Ford

No comments:

Post a Comment