typescript WebStorm 2016.3 错误:对装饰器的实验性支持是一项功能,在未来版本中可能会发生变化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40728785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 04:01:21  来源:igfitidea点击:

WebStorm 2016.3 error: Experimental support for decorators is a feature that is subject to change in a future release

angularmeteortypescriptphpstormwebstorm

提问by CommonSenseCode

Hi updated to latest WebStorm and I'm now getting this error:

嗨,更新到最新的 WebStorm,我现在收到此错误:

Error:(52, 14) TS1219:Experimental support for decorators 
is a feature that is subject to change in a future release. 
Set the 'experimentalDecorators' option to remove this warning.

But in my tsConfig experimentalDecoratorsare set to true:

但是在我的 tsConfigexperimentalDecorators中设置为 true:

{
  "version": "1.5.0",
  "compilerOptions": {
    //...,
    "experimentalDecorators": true,   // <======== HERE
    //...,
  },
  "files": [
    //...
  ],
  "exclude": [ "node_modules" ]
}

回答by anstarovoyt

WS2016.3applies config settings to a file only if the file is included in 'files' or 'include' tsconfig.json section. [More info about tsconfig.json]

WS2016.3仅当文件包含在 'files' 或 'include' tsconfig.json 部分时才将配置设置应用于文件。[关于 tsconfig.json 的更多信息]

So the config must include all project files (or if you have several parts of the app you can have several tsconfig.json files). Otherwise typescript service uses default typescript options for the file.

因此,配置必须包含所有项目文件(或者,如果您有多个应用程序部分,则可以有多个 tsconfig.json 文件)。否则,打字稿服务使用文件的默认打字稿选项。

Preferred solution

首选方案

Your tsconfig.jsonshould be:

你的tsconfig.json应该是:

{
  "version": "1.5.0",
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true, 
    "sourceMap": true,
    "listFiles": true,
    "isolatedModules": false,
    "moduleResolution": "node",
    "suppressImplicitAnyIndexErrors": true
  },
  "include": [
    "typings/thera/thera.d.ts",
    "typings/browser.d.ts",
    "typings/main.d.ts",
    "typings/meteor.d.ts",
    "typings/meteor_server.d.ts",
    "your_app_directory/**/*" 
  ],
  "exclude": [ "node_modules" ],
  "compileOnSave":false //not required but is suggested for meteor projects
}

Another solution

另一种解决方案

You can specify default options in the TypeScript settings (track changesoption should be unchecked if you don't want auto compilation):

您可以在 TypeScript 设置中指定默认选项(track changes如果您不想自动编译,则应取消选中该选项):

TypeScript Settings

打字稿设置

Note:If you don't like the new behaviour you can disable the typescript service integration in "File | Settings | Languages & Frameworks | TypeScript" -> "Use TypeScript service".

注意:如果您不喜欢新行为,您可以在“文件 | 设置 | 语言和框架 | TypeScript”->“使用 TypeScript 服务”中禁用打字稿服务集成。