【问题标题】:WebStorm 2016.3 error: Experimental support for decorators is a feature that is subject to change in a future releaseWebStorm 2016.3 错误:对装饰器的实验性支持是一项可能在未来版本中更改的功能
【发布时间】:2017-04-05 08:33:31
【问题描述】:

您好,已更新到最新的 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.

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

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

【问题讨论】:

  • 可以试试this answer吗?
  • 您的 tsconfig.json 不包含项目文件
  • @anstarovoyt 你这是什么意思?
  • @Mr.EasyAnswersMcFly 请看下面我的解释

标签: angular meteor typescript phpstorm webstorm


【解决方案1】:

WS2016.3 仅当文件包含在 'files' 或 'include' tsconfig.json 部分中时才会将配置设置应用于文件。 [More info about tsconfig.json]

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

首选解决方案

您的 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
}

另一种解决方案

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

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

【讨论】:

  • 或者直接重启IDE
  • 2020 年仍然有效。谢谢!我一直在到处寻找这个问题。
【解决方案2】:

也适用于 WebStorm 2020.1.2。谢谢。

【讨论】:

    【解决方案3】:
    1. 打开文件 -> 设置 -> 语言和框架 -> 打字稿
    2. 在选项输入中添加--experimentalDecorators --moduleResolution mode

    点击右下角的应用按钮

    【讨论】:

      猜你喜欢
      • 2018-06-16
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 2018-01-16
      • 2019-02-24
      • 1970-01-01
      • 2017-02-25
      • 1970-01-01
      相关资源
      最近更新 更多