-
-
Notifications
You must be signed in to change notification settings - Fork 256
Add support for computed class property names (#120) #121
Conversation
The CI failures (on Node 5 only, out of the whole build matrix) appear to be unrelated to the PR's content. (Right?) |
** Depends on babel/babylon#121 ** * `babel-types`: Add `computed` field to `ClassProperty` * `babel-plugin-transform-class-properties`: handle computed property names correctly * `babel-generator`: add tests for class properties (computed/literal, static/instance)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
Thanks for contributing. This looks really good, the only thing that I'm worried about is how the ambiguous cases are handled. For example this class:
Does it contain two or one properties? I would assume one with a value of |
Current coverage is 94.03% (diff: 100%)
|
My immediate answer is that ASI applies like everywhere else (and there are existing tests for literal-named properties reflecting this). Need to do a little bit of research before I can add more info. |
I found this Not sure what the current status is, but semicolons might be required in the case i posted. |
There's some existing tests, which cover the ASI rules in this case for computed methods. |
Good catch. So it probably also throw with properties. |
There's also tc39/proposal-class-public-fields/pull/45 (an open PR at the moment) which suggests the semicolon is not in the spec, but IMHO it's safe to assume it will be (given past discussions and the nontrivial ambiguity otherwise). |
@danez your |
Yeah ref babel/babel#3225 and revert pr babel/babel#3332 Can cc @jeffmo |
Looks fine to me? We made semicolons necessary before but it was reverted |
The tests look right to me |
@jeffmo what will the spec say about this case? Or is it not yet decided?
|
@danez: Grammatically, that would be the same as:
This is all just the practical fallout of supporting ASI in the language. |
* Support computed class property names (#4499) ** Depends on babel/babylon#121 ** * `babel-types`: Add `computed` field to `ClassProperty` * `babel-plugin-transform-class-properties`: handle computed property names correctly * `babel-generator`: add tests for class properties (computed/literal, static/instance) * doc: Update babel-types with ClassProperty.computed * chore(package): update babylon to v6.11.0 * babel-types: move ClassProperty.computed to be last builder arg
* Support computed class property names (babel#4499) ** Depends on babel/babylon#121 ** * `babel-types`: Add `computed` field to `ClassProperty` * `babel-plugin-transform-class-properties`: handle computed property names correctly * `babel-generator`: add tests for class properties (computed/literal, static/instance) * doc: Update babel-types with ClassProperty.computed * chore(package): update babylon to v6.11.0 * babel-types: move ClassProperty.computed to be last builder arg
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
…ue`) See README.md for documentation. This feature is blocked on the following Babel PRs/issues: * babel/babel#4500 * babel/babylon#121 * babel/babel#4337 * babel/babel#4230 (partially)
First time contributor here - someone please check this for sanity 😄
I think this implements #120 quite completely. I'm working on a PR for the corresponding changes required in Babel, tracked by babel/babel#4499.