如何在VS2015中禁用以下错误提示?
TS1219 实验性的装饰器支持是一个可能会在未来版本中发生变化的功能。请指定“--experimentalDecorators”以移除此警告。
我正在尝试使用Angular2注解。我尝试手动将下面的内容添加到项目文件,但没有成功:
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
我也安装了TypeScript 1.5.0 beta扩展。
如何在VS2015中禁用以下错误提示?
TS1219 实验性的装饰器支持是一个可能会在未来版本中发生变化的功能。请指定“--experimentalDecorators”以移除此警告。
我正在尝试使用Angular2注解。我尝试手动将下面的内容添加到项目文件,但没有成功:
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
我也安装了TypeScript 1.5.0 beta扩展。
Visual Studio 2015支持从Typescript版本1.8开始使用tsconfig文件。在项目的根目录下创建tsconfig.json文件,并添加experimentalDecorators
编译器选项。
示例:
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
"experimentalDecorators": true
}
}
对于旧版本:
https://github.com/Microsoft/TypeScript/issues/3934
如果您有项目文件,则 tsconfig 将不受尊重。项目文件优先。我们仍在完善 VS 项目和 tsconfig 之间的集成方式,因为您可以在两者中指定编译器选项。
因此,要禁用错误消息,请右键单击项目文件、取消加载项目,然后右键单击编辑项目文件,在文件末尾应该有一个配置部分,请添加:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
....
<TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>
</PropertyGroup>
保存并重新加载。
您可能还需要TypeScriptEmitDecoratorMetadata来映射--emitDecroatorMetadata。
VS 2015社区版更新3
。谢谢 :) - SampathexperimentalDecorators
作为编译选项添加进去。
示例:
{
"version": "1.5.0",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"sourceMap": true,
"listFiles": true,
"outDir": "dist",
"experimentalDecorators": true
}
}
tsconfig.json
文件后,不要忘记重启 IDE。至少在我使用 VS Code 时是这样的。 - Barry TormeyTypeScriptExperimentalDecorators
。<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
我复制了完整的PropertyGroup以便您可以找到添加位置:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptRemoveComments>false</TypeScriptRemoveComments>
<TypeScriptSourceMap>true</TypeScriptSourceMap>
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptJSXEmit>None</TypeScriptJSXEmit>
<TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
<TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
<TypeScriptModuleKind>System</TypeScriptModuleKind>
<TypeScriptOutFile />
<TypeScriptOutDir />
<TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
<TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
<TypeScriptMapRoot />
<TypeScriptSourceRoot />
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
</PropertyGroup>
我发现我还需要添加元数据标签
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<!--other -->
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
<TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata>
</PropertyGroup>
<TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators>
"experimentalDecorators": true
为了更好地理解,除了以上错误,我还遇到了以下问题:
上述步骤解决了我的特定错误。希望对你有所帮助。
仅使用Nuget软件包管理器,我就能将我的TypeScript升级到最新版本,并解决了这个问题。
据我所见,这与TypeScript版本冲突有关。
请确认您的TypeScript版本,并进行适当的升级或降级以解决此问题。
http://www.cmichaelgraham.io/aurelia-typescript-samples/vs2015-samples/vs2015-samples.html
<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>
...........
<TypeScriptAdditionalFlags> $(TypeScriptAdditionalFlags) --emitDecoratorMetadata --experimentalDecorators </TypeScriptAdditionalFlags>
这个错误出现是因为我误将一个新文件的扩展名命名为“.js”而不是“.ts”。 将文件扩展名更改为“.ts”后问题解决了。
我有类似的问题。我有一些发现要分享。我也在使用 Angular 2(ng-book-2)。
我在使用什么?
IDE:WebStorm
TypeScript:1.6.2
时间:2015年10月10日
我在做什么?
我尝试将我的 app.ts 编译为 app.js;但是,我遇到了这个错误:
error TS5052: Option 'emitDecoratorMetadata' cannot be specified without specifying option 'experimentalDecorators'.
这是我的 tsconfig.json AFTER
{
"version": "1.5.0",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true
},
"filesGlob": [
"./**/*.ts",
"!./node_modules/**/*.ts"
],
"files": [
"./app.ts",
"./typings/angular2/angular2.d.ts",
"./typings/es6-promise/es6-promise.d.ts",
"./typings/rx/rx-lite.d.ts",
"./typings/rx/rx.d.ts",
"./typings/tsd.d.ts"
]
}
这是我的 tsconfig.json AFTER
{
"version": "1.6.2",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"filesGlob": [
"./**/*.ts",
"!./node_modules/**/*.ts"
],
"files": [
"./app.ts",
"./typings/angular2/angular2.d.ts"
]
}
将tsconfig.json从之前更改为之后有效地解决了我的两个问题。一个是上面的问题,另一个是下面的问题。后一个问题在这里讨论 angular2 with ES6 should not reference es6-promise
typings/es6-promise/es6-promise.d.ts(11,15): error TS2300: 重复标识符'Promise'。 typings/es6-promise/es6-promise.d.ts(42,16): error TS2300: 重复标识符'Promise'。 typings/es6-shim/es6-shim.d.ts(475,11): error TS2300: 重复标识符'Promise'。 typings/es6-shim/es6-shim.d.ts(552,13): error TS2300: 重复标识符'Promise'。