Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ES6 / ES7 support in Visual Studio 2015 Community

Tags:

I'm hearing that VS 2015 is supporting the new js syntax but when I open up a project written using aurelia.js in this IDE intellisense complains about many, many things eg.

export class UpperValueConverter {   toView(value){     return value && value.toUpperCase();   } } 

I have the WebEssentials 2015 installed. Still nothing seems to work... Probably an important information is that my current VS installation is a fresh one, so I didn't mess up any settings.

like image 720
Marek M. Avatar asked Jul 21 '15 16:07

Marek M.


People also ask

Does Visual Studio community support JavaScript?

Overview. Visual Studio 2019 provides rich support for JavaScript development, both using JavaScript directly, and also using the TypeScript programming language, which was developed to provide a more productive and enjoyable JavaScript development experience, especially when developing projects at scale.

What is the difference between ES6 and ES7?

Introducing the new features that ECMAScript 2016 (ES7) adds to JavaScript. Since ECMAScript 2015 (also known as ES6) was released, it has introduced a huge set of new features. They include arrow functions, sets, maps, classes and destructuring, and much more.

Do all browsers support ES6 now?

ES6 is safe. Take a look at this chart. All the current browsers have full support to ES6. Well if you take a closer look you may find some “unsupported” or “partially supported” features but I bet you will never have chance to use those unsupported features.


2 Answers

Javascript is a language. ES6 is a version of Javascript. Microsoft has not supplied a intellisense mapping file for it. The suggestions on this post suggest using javascript frameworks/APIs which do provide intellisense mapping files. These suggestions do not answer the question on how to stop getting intellisense errors for new Javascript versions. Unless someone creates that mapping file and provides a URL for us to reference from Visual Studio/tools/Javascript/Intellisence/references you will get syntax errors writing straight ES6 Javascript.

like image 136
user7085375 Avatar answered Oct 07 '22 17:10

user7085375


For using the new ES6/ES7 syntax you have to use a transpiler. You have three options Traceur, Babel or TypeScript. These will transpile the new syntax to the current ES5 syntax which the current browsers support. Aurelia has good support for Babel or TypeScript.

Visual Studio 2015 includes TypeScript 1.5. So you have to create a TypeScript file (.ts) instead of a Javascript file (.js). TypeScript will transpile this to a ES5 .js file. The .js file is the one that runs in the browser.

When you open a Javascript file in Visual Studio it will handle this as a ES5 Javascript file and not as a ES6/ES7 Javascript file, so if you want to use Babel then you get syntax errors in the editor.

like image 20
Arjen de Blok Avatar answered Oct 07 '22 17:10

Arjen de Blok