如何摆脱 Angular4 项目的 Eclipse 中的experimentalDecorators警告

use*_*967 5 typescript angular

我刚刚使用 anglar4 cli 创建一个新项目,并开始出现以下错误。

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)

对于每个注释。

我之前没有使用 ng cli,所以我没有看到任何类似的警告。

我检查我的 tsconfig,

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types"
    ],

    "exclude": 
    [
        "node_modules",
        "**/*.spec.ts"
    ],

    "lib": [
      "es2016",
      "dom"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

没什么特别的。

如何删除 Eclipse 中 Angular4 项目的警告?这是非常烦人的误报。

我在 Eclipse 中使用了 typescript 插件。

小智 5

我遇到了类似的问题, "allowJs": true,在 tsconfig.json 中添加 CompilerOptions 解决了这个问题。我希望它对其他人有帮助。

添加上述内容后,我的 tsconfig.json 如下所示。

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowJs": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)


小智 1

由于您的 tsconfig 文件具有正确的标志,因此我必须假设正在运行的 TypeScript 编译器没有读取该配置文件。它要么读取不同的配置文件,要么根本不读取。该 tsconfig 文件中的其他标志是否会影响编译?

也许检查 TypeScript 插件,看看它是否在其他地方寻找该文件。