Enabling Decorators Support in TypeScript 1.5, Visual Studio 2015

less than 1 minute read,

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):

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

Tags:

Updated:

Comments

Greg Gum

Didn’t realize that the tsconfig.json was not recognized by Visual Studio. Your solution worked for me. Thanks.

Leave a comment

Your email address will not be published. Required fields are marked *

Loading...