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

Com*_*ode 12 phpstorm webstorm meteor typescript angular

嗨更新到最新的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.
Run Code Online (Sandbox Code Playgroud)

但在我的tsConfig experimentalDecorators中设置为true:

{
  "version": "1.5.0",
  "compilerOptions": {
    //...,
    "experimentalDecorators": true,   // <======== HERE
    //...,
  },
  "files": [
    //...
  ],
  "exclude": [ "node_modules" ]
}
Run Code Online (Sandbox Code Playgroud)

ans*_*oyt 19

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

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

首选解决方案

你的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
}
Run Code Online (Sandbox Code Playgroud)

另一种方法

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

TypeScript设置

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

  • 或者只是重启IDE (8认同)

yuv*_*uva 8

也适用于 WebStorm 2020.1.2。谢谢。

在此处输入图片说明


Nan*_*ish 6

  1. 打开文件 -> 设置 -> 语言和框架 -> 打字稿
  2. 在选项输入添加 --experimentalDecorators --moduleResolution mode

在此处输入图片说明

点击右下角的应用按钮