Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES7 Class Properties throws 'Unexpected token =' #2304

Closed
voronianski opened this issue Apr 13, 2015 · 8 comments
Closed

ES7 Class Properties throws 'Unexpected token =' #2304

voronianski opened this issue Apr 13, 2015 · 8 comments

Comments

@voronianski
Copy link

Jeff Morrison's stage 0 class property initializers proposal fills the void of property composition on classes.

Currently when using:

class Person {
  firstName = 'John'; // jshint error 'Unexpected token ='
  static lastName = 'Doe';
}

console.log(new Person().firstName); // "John"
console.log(Person.lastName); // "Doe"

Any plans to support such feature? Or maybe I'm missing an option? Thanks!

@jugglinmike
Copy link
Member

It would be unwise for JSHint to commit to supporting any stage 0 proposals.

@rwaldron
Copy link
Member

You can prevent the error by demarcating non-standard portions with an ignoreDelimiter:

class Person {
  //start-non-standard
  firstName = 'John';
  static lastName = 'Doe';
  //end-non-standard
}

.jshintrc

...
ignoreDelimiters: [
  { start: "start-non-standard", end: "end-non-standard" },
],
esnext: true
...

@voronianski
Copy link
Author

@rwaldron thanks!

@rwaldron
Copy link
Member

@voronianski you're welcome!

@hackel
Copy link

hackel commented Sep 26, 2015

It's up to stage 1 now: https://github.com/jeffmo/es-class-static-properties-and-fields
I know that's still not very far along, but I would love to use this without littering my code with start-non-standards in every class!

@jugglinmike
Copy link
Member

@hackel In the time since this feature request was made, we've formalized our requirements for new language features:

http://jshint.com/blog/new-lang-features/

We'll be happy to accept patches once the "class properties" proposal reaches stage 2!

@MikeShi42
Copy link

Just an update, it's at stage 2 now: https://github.com/tc39/proposals. Perhaps time to re-open this issue?

@jugglinmike
Copy link
Member

Now that this proposal has reached stage 2, I have created an issue to track support within JSHint. See gh-3139.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants