简体   繁体   中英

Visual Studio Code 'experimentalDecorators' Issue for Angular Build

I am having an issue with VSC where all my typescript classes are triggering the intellisense and coming up with this warning:

"[ts] Experimental support for is a feature that is subject to change in a future build. Set the 'experimentalDecorators' option to remove this warning."

This is a documented issue, with various fixes documented in these posts:

However I am using a now more recent version of VSC (it was actually me updating it today that seems to have triggered something), and with that none of the solutions mentioned here seem to work.

I have:

  • Added the "typescript.tsdk": "../node_modules/typescript/lib" option to my .vscode settings
  • Removed various lines in the tsconfig.json file in the root of the app including lib, baseUrl and others, fully reopening VSC inbetween tries
  • Tried alternate Typescript versions in my package.json
  • Restarted my computer on the off chance

Here's my current tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ]
  }
}

I am using VSC version 2.3.2 and my TS version in my package.json is set to "typescript": "~2.2.0".

Is there something here I'm missing?

this is what what worked for me:  
tsconfig.js (relevant part):
{
  "compilerOptions": {
    ...
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "outDir": "dist",
    ...
  },
  "include": [
    "src/index.ts"
  ]
}

Here is the full file:

{
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "allowJs": true,
    "lib": [
      "es6"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "dist",
    "sourceMap": true,
    "target": "es6"
  },
  "include": [
    "src/db/**/*.ts",
    "src/index.ts"
  ]
}

Basically I just added the include attribute instead of using the files attribute.

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