繁体   English   中英

角度构建的Visual Studio代码“ experimentalDecorators”问题

[英]Visual Studio Code 'experimentalDecorators' Issue for Angular Build

我在VSC上遇到问题,我的所有打字稿类都触发了智能感知并提出以下警告:

“ [ts]的实验性支持是一项功能,该功能在将来的版本中可能会更改。设置'experimentalDecorators'选项可删除此警告。”

这是一个已记录的问题,这些帖子中记录了各种修复程序:

但是,我使用的是VSC的最新版本(实际上是我今天对其进行了更新,似乎已经引起了某些问题),因此此处提到的解决方案似乎都无效。

我有:

  • 在我的.vscode设置中添加了“ typescript.tsdk”:“ ../node_modules/typescript/lib”选项
  • 删除了应用程序根目录中tsconfig.json文件中的各行,包括lib,baseUrl等,在尝试之间完全重新打开了VSC
  • 在我的package.json中尝试了替代Typescript版本
  • 重新启动计算机

这是我当前的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"
    ]
  }
}

我正在使用VSC版本2.3.2,并且package.json中的TS版本设置为“ typescript”:“〜2.2.0”。

这里有什么我想念的吗?

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

这是完整的文件:

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

基本上,我只是添加了include属性,而不是使用files属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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