Skip to content

Extract computed keys from the class closure#13600

Merged
nicolo-ribaudo merged 4 commits intobabel:mainfrom
nicolo-ribaudo:yield-await-class-key
Jul 26, 2021
Merged

Extract computed keys from the class closure#13600
nicolo-ribaudo merged 4 commits intobabel:mainfrom
nicolo-ribaudo:yield-await-class-key

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo commented Jul 26, 2021

Q                       A
Fixed Issues? Fixes #8300
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The other two tests are bugs which have never been reported, but which are also fixed by this new computed keys approach.

cc @benjamn

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Classes labels Jul 26, 2021
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Jul 26, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/47547/

@nicolo-ribaudo nicolo-ribaudo force-pushed the yield-await-class-key branch from 7b31316 to 4536255 Compare July 26, 2021 16:44
static [log.push(4)]() {}
}

expect(log).toEqual([1, 2, 3, 4]);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main this is 1, 3, 2, 4.

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Jul 26, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 451ac46:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Copy link
Copy Markdown
Contributor

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (this should resolve facebook/regenerator#487). Thanks @nicolo-ribaudo!

};

node.body.body.forEach(elem => {
if (!t.isClassMethod(elem) || !elem.computed) return;
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung Jul 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why should we exclude non-method elements? I think we are preserving the order of ClassElementName evaluation and thus we should apply it to any named class elements.

Ah I see, the transform-classes only take care class methods.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this plugin doesn't support class fields.

@nicolo-ribaudo nicolo-ribaudo merged commit 790c518 into babel:main Jul 26, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the yield-await-class-key branch July 26, 2021 21:31
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Jul 30, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 26, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Classes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Yield and await in class methods keys

6 participants