You'll need to target ECMAScript v5, ie pass the -target ES5
argument to the compiler. This needs to be set in the project files target configuration.
I don't know if VS has any built in mechanims for editing target configurations, so i can only tell you how to do it manually. Simply open your .csproj
project file, look for the Target
node where the TypeScript compiler command is located, and add the -target ES5
argument.
In my config it looks like this:
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" -target ES5 @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
Update
As of version 0.8.1.0, the hardcoded version dependency was removed and support for source maps was added, and so the Target
node now looks like this by default:
<Target Name="BeforeBuild">
<Message Text="Compiling TypeScript files" />
<Message Text="Executing tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc$(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
</Target>
Injecting the target
argument is still pretty easy, simply put it after tsc
or $(TypeScriptSourceMap)
:
<Message Text="Executing tsc --target ES5 $(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc --target ES5 $(TypeScriptSourceMap) @(TypeScriptCompile ->'"%(fullpath)"', ' ')" />