Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
712 views
in Technique[技术] by (71.8m points)

angular - Visual Studio 2015 RC Typescript experimental decorators error

How do I disable the following error in VS2015?

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

enter image description here

I'm trying to use Angular2 annotations. I tried adding the following manually to the project file with no luck:

<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>

I've also install the TypeScript 1.5.0 beta extension.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Visual Studio 2015 supports tsconfig files starting with Typescript version 1.8. Create tsconfig.json file at the root of your project and add experimentalDecorators compiler option.

Example:

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "commonjs",
    "sourceMap": true,

    "experimentalDecorators": true
  }
}

For older versions:

https://github.com/Microsoft/TypeScript/issues/3934

If you have a project file, tsconfig will not be honored. the project file takes precedence. We are still flushing the integration story between a VS project and a tsconfig as you can specify compiler options in both.

so to disable the error message, right-click on project file, unload project, then right-click edit the project file, At the end of the file there should be a config section, add:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  ....
  <TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>
</PropertyGroup>

save and reload.

You may also need TypeScriptEmitDecoratorMetadata to map --emitDecroatorMetadata


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...