Enabling Decorators Support in TypeScript 1.5, Visual Studio 2015

Finally installed VS2015, I got the following error in my TypeScript project:

Error    TS1219    Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.

Ok. So, how exactly do you do this if you're not the one invoking the TSC compile action? Visual Studio TypeScript plugin is invoking the compiler option. Hmm. tsconfig.json compiler config doens't seem to be picked up by the TypeScript plug-in.

To enable decorator support, unload your TypeScript project. Right click, Edit Project .csproj. Find the TypeScript compiler option section and add the following (Line 14 and 15):

Code Snippet
  1. <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  2.   <TypeScriptModuleKind>amd</TypeScriptModuleKind>
  3.   <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
  4.   <TypeScriptTarget>ES5</TypeScriptTarget>
  5.   <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
  6.   <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
  7.   <TypeScriptOutFile />
  8.   <TypeScriptOutDir />
  9.   <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
  10.   <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
  11.   <TypeScriptSourceMap>True</TypeScriptSourceMap>
  12.   <TypeScriptMapRoot />
  13.   <TypeScriptSourceRoot />
  14.   <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
  15.   <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
  16. </PropertyGroup>

Also, seems like the TypeScript 1.5 RTM plugin will respect the decorator compile options when you use SAVE-ON-COMPILE. :)

Hope that helps,
Brian Chavez

2 Comments Filed Under [ ASP.NET ]