Visitar URL original
Extract computed keys from the class closure by nicolo-ribaudo 路 Pull Request #13600 路 babel/babel 路 GitHub
Skip to content

Extract computed keys from the class closure - #13600

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

nicolo-ribaudo merged 4 commits into
babel:mainfrom
nicolo-ribaudo:yield-await-class-key

Conversation

@nicolo-ribaudo

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

Copy link
Copy Markdown
Member
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

babel-bot commented Jul 26, 2021 •

Copy link
Copy Markdown
Collaborator

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

codesandbox-ci Bot commented Jul 26, 2021 •

Copy link
Copy Markdown

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

@benjamn benjamn left a comment

Copy link
Copy Markdown
Contributor

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;

@JLHwung JLHwung Jul 26, 2021 •

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/babel-plugin-transform-classes/src/transformClass.ts Outdated
@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