**~~ NOTE: This is a Stage 0 proposal. ~~**
This proposal has been moved to https://github.com/jeffmo/es-class-properties.
Please direct all future feedback to that repo in the form of directed issues.
**~~ NOTE: This is a Stage 0 proposal. ~~**
Please direct all future feedback to that repo in the form of directed issues.
@jeffmo Even if this have been moved, you might want to update the gist to show that this is currently in stage 2, not stage 0. (Or atleast it says stage 2 here, but this lists it as a stage 1 draft...)
*EDIT: it does look like it is indeed in stage 2, according to this list
Accepting
class Whatever{
someSymbolThatIsAFunction(){
// yeah they call me a method but I am of the Function type
}
}
but not
class Whatever{
someSymbolThatIsNotAFunction = 1;
}
is to violate JS syntax basics.
so are semicolons required after each instance property set using this proposed syntax? otherwise a criticism i have is that the class body is messier and looks too much like any other set of statements of a regular function, and parsing things like *ident (){}
is much harder
No, semicolons are not required; they follow normal ASI rules and may come automatically. The grammar contains semicolons, just as it does at the end of normal statements which are also subject to ASI.
Should be updated from "stage 0" in the description of this gist to "stage 2" @jeffmo. Thanks for the information 👌
I'm totally for class properties, I'm not JavaScript developer, but PHP developer, and first time I wanted to specify initial state in ES6 I tried to use:
state = { count: 0 };
which is the first obvious thing to do, furthermore for static properties. This is easy and logical. I think it's good Idea to borrow some classes logic from different languages, like Traits for mixing from PHP, interfaces for inverting dependencies, so on.