-
Notifications
You must be signed in to change notification settings - Fork 588
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
[JavaScript] Add support for class fields #1292
Conversation
…e.modifier. Static keyword is no longer recognized in object literals.
I very much appreciate all of the work you've been doing on the JavaScript syntax recently. I know lots of users are benefitting from your hard work. I think that #1269 outlines that this currently has no implementations. I feel like once Babel or a browsers supports it, then I'd be more keen on merging it. Mostly because every feature we add increases the complexity, and having things in heavy flux implemented here are just going to make things more complicated in the future. Contributors will have to dig through history to understand why the implementation is as it is. Perhaps we can merge in some of the foundational stuff in now and leave the proposals in a PR for once there is someone implementing them? |
Public class fields are implemented in Babel and are widely used. Private fields are implemented in Babel's parser, but the transform is not yet finished. In addition, the entire spec (including private fields) is at Stage 3, which means that it should be very stable. It probably won't move to Stage 4 until after it's actually shipping in major browsers. (Stage 4 requires "Two compatible implementations which pass the acceptance tests", although one of them may be a transpiler like Babel.) Expected changes are "Limited: only those deemed critical based on implementation experience". In the unlikely event that there are any changes to the proposal, it is even more unlikely that the syntax would be affected; late-stage changes tend to be esoteric tweaks to obscure semantics. On the other hand, in my experience there are a lot of developers actively using class fields, including my own company. Without explicit support in the If we want to be maximally conservative, what about commenting out private field support until Babel supports it? |
Just to add on to this: I would suggest that a conservative standard might be that we should implement "experimental" features when:
Stage 3 is the gold standard indicating that a feature is ready for implementation. It must have a complete formal specification and sign-offs from various reviewers and editors. In addition, "The solution is complete and no further work is possible without implementation experience, significant usage and external feedback." This is the point at which most major browser vendors will begin shipping the feature, and indeed it cannot advance to Stage 4 without "[t]wo compatible implementations which pass the acceptance tests" and "[s]ignificant in-the-field experience with shipping implementations". Stage 2 means that a feature is largely complete, but not totally finalized. It is required that "all major semantics, syntax and API are covered", and "[t]he committee expects the feature to be developed and eventually included in the standard". It is expected that features in Stage 2 will be implemented by transpilers and other tools and often by major browsers (usually behind dev flags). Having a working implementation means that actual developers will be using the feature in production code. Although it is possible for a feature's syntax to change at this stage, it is very unusual. The standards committee actively tries to avoid making changes that would break Babel, and from reading their meeting notes you can easily get a sense of whether there is any significant syntax risk. |
@wbond Any thoughts on the standard described above? |
@Thom1729 I think those standards for inclusion sound reasonable. |
…erties [JavaScript] Add support for class fields
Implements the class fields proposal. See #1269 for more discussion. Also resolves #1238 and partially resolves #876.
Outline of changes:
static
keyword in object literals. It should be interpreted as an identifier.static
asstorage.modifier
. It was previously scoped asstorage.type
.Relevant to tc39/proposal-class-fields#57.