Eon
Eon

Reputation: 3974

Why does the javascript "class" keyword display as a error in VS2013

I have been working alongside my boss on a new site. He uses Visual Studio 2013, I use Visual Studio 2015. For some reason, the Javascript "class" keyword displays as an error on his copy of Visual Studio, but displays fine on my side:

Error on my boss's VS2013 instance

This shouldn't break the site, but it seems to mess with 2013 by displaying what's in the screenshot above.

Why does this happen on VS2013? To reiterate - it doesn't happen on my 2015 edition.

Upvotes: 1

Views: 754

Answers (2)

Anders Marzi Tornblad
Anders Marzi Tornblad

Reputation: 19305

Visual Studio 2013 simply does not support more recent versions of EcmaScript. Remember that Visual Studio 2013 is almost four years old, and the current definition of the class keyword is in EcmaScript 2015, which was suggested after Visual Studio 2013 was released. Before EcmaScript 2015, the class keyword was reserved but considered a syntax error, so Visual Studio is actually doing the right thing by marking it as an error.

Here is some more information that might help you get EcmaScript 6 support in Visual Studio 2013:

Also, if your boss is not debugging the JavaScript code using Visual Studio (or writing any), they can simply turn off JavaScript syntax checking.

Upvotes: 2

Quentin
Quentin

Reputation: 943564

The class keyword is a new edition to JavaScript. It was only standardised in ES6 from June 2015.

VS 2013 is simply too old to support it (as, for that matter, is Internet Explorer 11).

Upvotes: 2

Related Questions