Visual Studio Code supports the latest javascript
Visual Studio Code is a popular development environment for JavaScript.
ES7 alias ES2016 is the latest JavaScript feature, Every year, the ECMAScript community releases new features, and frameworks like react, angular, and vuejs frameworks are using ES7 or ES6 via Babel plugins.
Visual Studio Code provides syntax and auto code enable for every language, and does not support the latest JavaScript by default. There are several ways to configure the latest feature.
- Update Visual Studio code to the latest version
- third-party plugin
- Configure settings
This blog post will take you to configure ES6/ES7 Syntax support.
updates latest visual studio code
Go to visual studio code site and download the latest version of vscode and install as per vscode-installation . By default, new JavaScript features work in the latest versions, still, some of the most recent features do not work, in that case, use another approach as described below.
Enable ES7/ES2016 Syntax in VScode
Create a jsconfig.json file in your project and the following entries in it.
{
"compilerOptions": {
"target": "ES7",
"module": "commonjs"
}
}
This will enable the compilation and syntax support of ECMAScript 2016 code.
With these features, some of the features will not work or this approach not work, consider other approach.
Configure settings.json - javascript.validate.enable
First, you need to disable the inbuilt validation to avoid syntax validation errors caused by to Latest JavaScript not being defined.
settings.json
javascript.validate.enable=false
To disable validation in JavaScript projects, you have to configure the settings
javascript.implicitProjectConfig.checkJs": false
disable in typescript
configJS:false
In VSCODe, add the below properties.
jshint.options: { "esversion": 6 or 7 }