angular - 升级到 Angular 10 后 VS 代码编辑器中的装饰器错误

标签 angular typescript visual-studio-code

Error: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
在具有相同项目的 Angular 9 中没有这样的错误。
Angular10 现在添加了 tsconfig.base.json 文件。tsconfig.json文件更新为:
{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}
tsconfig.app.json:
{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}
tsconfig.base.json:
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
  }
}
我注意到 tsconfig.json 的内容Angular 9 中的内容已移至 tsconfig.base.json在 Angular 10 中。

最佳答案

我在刚刚安装了 Angular 10 的 VSCode 中遇到了同样的问题,我检查了并且已经添加了实验性装饰器,但是,我还是收到了那个烦人的警告和波浪线,所以我所做的,我只是看到 vscode 正在使用旧版本的 typescript 所以,我点击了 vscode 的右下 Angular ,它显示了 3.8.3 版,然后我将其更改为安装了 angular 的最新版本,我的问题得到了解决。
让我知道它是否有帮助并解决了您的问题。
谢谢你

关于angular - 升级到 Angular 10 后 VS 代码编辑器中的装饰器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62614633/

相关文章:

Angular-MDC 返回 "No mixin named mdc-top-app-bar-fill-color"

angular - Visual Studio Code 无法解析 Angular tsconfig 路径

typescript - Chai 期望使用 Typescript 抛出与相同异常不匹配的异常

typescript - 允许没有未使用的变量规则的 typescript 编译

visual-studio-code - 使用 VS Code 时如何解决 Rust 中的 "unresolved import"?

go - 如何为未声明的库自动完成?

javascript - 推送到表单内部数组时丢失双向绑定(bind)(Angular 2)

Angular:如何解决SameSite Cookie问题

angular - activatedRoute 快照在 TS 类构造函数中不起作用

typescript - 在 Typescript 中导出函数的返回类型