Is there a way to turn on ES6/ES7 syntax support in vscode?

前端 未结 7 1091
既然无缘
既然无缘 2020-12-02 14:51

Edit 3: Starting in version 0.4.0, ES6 syntax can be turned on by adding a jsconfig.json file to the project folder with the following contents:

7条回答
  •  天命终不由人
    2020-12-02 15:42

    Adding to the above answers...

    As per Docs of VS Code..

    Make sure that you place the jsconfig.json at the root of your JavaScript project and not just at the root of your workspace. Below is a jsconfig.json file which defines the JavaScript target to be ES6 and the exclude attribute excludes the node_modules folder.

    {
        "compilerOptions": {
            "target": "ES6"
        },
        "exclude": [
            "node_modules"
        ]
    }
    

    Here is an example with an explicit files attribute.

    {
        "compilerOptions": {
            "target": "ES6"
        },
        "files": [
            "src/app.js"
        ]
    }
    

    The files attribute cannot be used in conjunction with the exclude attribute. If both are specified, the files attribute takes precedence.

    also try editing the "target" property in tsconfig.json

    {
      "compilerOptions": {
        "target": "es5",//es6
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
      },
      "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
      ]
    }
    

提交回复
热议问题