简体   繁体   English

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

[英]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: 我在VSC上遇到问题,我的所有打字稿类都触发了智能感知并提出以下警告:

"[ts] Experimental support for is a feature that is subject to change in a future build. Set the 'experimentalDecorators' option to remove this warning." “ [ts]的实验性支持是一项功能,该功能在将来的版本中可能会更改。设置'experimentalDecorators'选项可删除此警告。”

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

I have: 我有:

  • Added the "typescript.tsdk": "../node_modules/typescript/lib" option to my .vscode settings 在我的.vscode设置中添加了“ typescript.tsdk”:“ ../node_modules/typescript/lib”选项
  • Removed various lines in the tsconfig.json file in the root of the app including lib, baseUrl and others, fully reopening VSC inbetween tries 删除了应用程序根目录中tsconfig.json文件中的各行,包括lib,baseUrl等,在尝试之间完全重新打开了VSC
  • Tried alternate Typescript versions in my package.json 在我的package.json中尝试了替代Typescript版本
  • Restarted my computer on the off chance 重新启动计算机

Here's my current tsconfig.json 这是我当前的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". 我正在使用VSC版本2.3.2,并且package.json中的TS版本设置为“ 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. 基本上,我只是添加了include属性,而不是使用files属性。

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

相关问题 Visual Studio 2017 Javascript如何设置'experimentaldecorators' - Visual Studio 2017 Javascript How to set 'experimentaldecorators' 无法在Visual Studio Code中使用TypeScript设置Angular 2 - Unable to setup Angular 2 with TypeScript in Visual Studio Code Visual Studio代码:找不到名字角? - Visual Studio Code: Cannot find name angular? 使用自定义本地主机的 Visual Studio 代码调试 Angular - Visual studio code debug Angular with custom localhost Angular2构建:仅在Visual Studio中找不到名称“ Promise” - Angular2 Build: Cannot find name 'Promise' only in Visual Studio 如何在visual studio代码中有效地遍历angular代码 - How to effectively traverse angular code in visual studio code 在 Visual Studio 中的 Release Build 中删除未使用的 css/js 代码 - Remove unused css / js code on Release Build in Visual Studio Visual Studio代码Sencha Ext JS扩展问题 - Visual Studio Code Sencha Ext JS Extension Issue 如何使用Visual Studio Code调试Angular 4单元测试 - How to debug a Angular 4 unit tests using Visual Studio Code Angular 8:Visual Studio Code 调试器是否正确捕获主题行为? - Angular 8: Does Visual Studio Code Debugger Catch Subject Behavior Correctly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM