Search code examples
msbuildtypescriptvisual-studio-2015ecmascript-6typescript1.5

VS2015: Build errors when building app with Typescript 1.5 and Experimental Decorators


I have looked high and low for the solution to this, and I have gotten close, but still having a little trouble.

The error:

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

This error appears for every usage of decorators. I have the MSBuild set up with

    <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
    <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>

and that removed half of the errors (compiler errors, not build errors). However, now I'm stuck with the build errors. The .ts files still get compiled to .js, no problem.*** But the exceptions get in the way of building the rest of the solution.

If any of this doesn't make sense, please let me know. I'm not the best with words.

Edit: I discovered that the .js is created upon save, not build. So anything relating to build is "broken."


Solution

  • I had the same problem. I ended up modifying the .csproj to change all TypeScriptCompile elements to just plain Content elements, and I used my own compile task (via Gulp).

    For example, <TypeScriptCompile Include="app.ts" /> became <Content Include="app.ts" />.

    I also removed any imports that referenced Typescript related MSBuild targets, i.e. <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />

    I still get IDE (and Resharper, if you use that) support for Typescript - I just explicitly tell Visual Studio not to handle any TS compilation for my project. It seems that the only downside is having to manage my Gulp tasks for compiling the Typescript. Using Task Runner Explorer extension for VS, adding the Gulp compilation task as part of the project's build, or just using the Gulp task inside of a gulp watch can mitigate the tradeoff.