在VSCode中关闭以下警告仅在定位ECMAScript 5及更高版本时才能使用访问者

时间:2017-08-20 01:58:03

标签: visual-studio-code

我写的类型脚本代码编译得很好。问题在于visual studio代码,我看到以下警告。

enter image description here

对此有一个类似的问题,但这是为了编译有效的tyepscript。我只看到上面的警告,我无法弄清楚如何将其关闭。

我读了更新你的tsconfig.json,但据我所知,我的是正确的。

我的tsconfig.json

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

1 个答案:

答案 0 :(得分:0)

如果你通过angular cli,ng new project创建一个应用程序,它将在项目的根文件夹中创建一个tsconfig.json,在src文件夹中创建一个。调用ng serve时的Web包使用项目根目录中的tsconfig.json,而vscode使用src文件夹中的那个。

|-tsconfig.json
|-src
  |-tsconfig.json

要解决:更新src文件夹中tsconfig.json的编译器选项,如下所示

添加"目标":" es2017"

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "allowJs": true,
        "target": "es2017"
    }
}