【问题标题】:Missing tsconfig.json file and Experimental Decorators warning in vsCodevsCode 中缺少 tsconfig.json 文件和 Experimental Decorators 警告
【发布时间】:2019-07-07 21:29:23
【问题描述】:

Angular 6.0.3global Angular CLI v6.0.8local Angular CLI v6.0.7)中,我突然在打开的每个组件上都遇到了智能感知错误:Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

我在这里尝试了接受答案中的说明:Experimental decorators warning in TypeScript compilation

但我的 tsconfig.json 文件已经有 "experimentalDecorators": true

我也尝试过关闭和重新打开visual studio code,单击文件树上的refresh 按钮,Reload Window 命令等等等等。 我认为我的问题可能在于我在文件结构中的任何地方都看不到tsconfig.json(所以也许Angular也看不到)。我相信它确实存在,因为我确实看到了tsconfig.app.json,并且这个文件有一个指向tsconfig.json 的链接,我可以通过ctrl + click 跟随tsconfig.json 文件。

我怎样才能找到tsconfig.json 的位置和/或使它与我的开发团队的其他成员一样出现在与tsconfig.app.json 相同的文件级别?

我的tsconfig.app.json 文件:

{
  "extends": "../tsconfig.json",  //I can ctrl + click here to go to tsconfig.json
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": []
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}  

我的(丢失/不可见)tsconfig.json 文件:

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

【问题讨论】:

  • 如果您可以使用 ctrl+click 跟随文件,那么 IDE 可能决定不显示它。您能否从文件系统中确认该文件确实存在?
  • 您是否尝试过您链接的问题中的任何其他答案(不仅仅是接受的)?您可能应该从那里开始。
  • @fridoo 是的,我做到了。其他的要么与我无关,要么不起作用。我尝试将 "typescript.tsdk": "node_modules/typescript/lib" 添加到 settings.json 无济于事。实际上,在重新启动时 vscode 警告我 node_modules/typescript/lib 不是有效路径。

标签: angular typescript visual-studio-code intellisense tsconfig


【解决方案1】:

啊 - 明白了。我意识到我看不到文件树最高级别的node_modules 文件夹,也看不到tsconfig.json。我不小心指示 vsCode 只打开 src 文件夹,而不是 src 和 node_modules 的父文件夹。

我打开了一个新的 vscode 窗口,关闭了旧的窗口,并确保当我单击文件 --> 打开文件夹时,我指向了包含 src 和 node_modules 的父文件夹。这也是 tsconfig.json 存在的层级,这也是我之前看不到的原因。

我认为智能感知错误消失了,因为 Angular 现在可以实际看到 tsconfig.json(它已经有“experimentalDecorators”:true)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 2018-08-24
    相关资源
    最近更新 更多