简体   繁体   中英

How to get rid of experimentalDecorators warning in Eclipse for angular4 project

I just used anglar4 cli to create a new project, and start getting below error.

Experimental support for decorators is a feature that is subject to change in a future release. Set 
 the 'experimentalDecorators' option to remove this warning.

For each annotation.

I did not use ng cli before, then I do not see any similar warning.

I check my 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"
    ]
  }
}

nothing is special.

How can I remove the warning in Eclipse for angular4 project? this is very annoying false alert.

I used typescript plugin in Eclipse.

I faced similar problem & Adding "allowJs": true, in the CompilerOptions in tsconfig.json solved the issue. I hope it helps others.

My tsconfig.json after adding above looks like below.

{
  "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"
    ]
  }
}

Since your tsconfig file has the correct flag, I'd have to assume the TypeScript compiler that is running is not reading that config file. It is either reading a different config file or none at all. Do the other flags in that tsconfig file affect the compile?

Perhaps check the TypeScript plugin to see if it is looking elsewhere for the file.

I had a similar situation where I was getting those errors in my pages, but my tsconfig.json file had the property set to true.

I am using VS Code, so I checked my Settings ( Ctrl + , on Windows). When I searched for "experimental", I found that the "Implicit Project Config: Experimental Decorators" setting was turned off. Check that, and the warning went away.

使用“experimental”作为搜索词的设置图片,显示“JS/TS > Implicit Project Config: Experimental Decorators”作为要设置的设置。

I'm using the editor Visual Studio Code, or VS Code for short, and encountered the same issue. The cause and solution may apply to Eclipse as well, though.

Whenever I, in my editor, open a folder that is on a lower level than the folder containing my tsconfig.json file, the editor starts displaying these warning messages. I believe that the editor doesn't "see" the tsconfig.json-file in this case.

Make certain that you add the "experimentalDecorators": true setting to your tsconfig.json file, and then open the folder that contains your tsconfig.json file in your editor and see if the warning messages disappear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM