Skip to content
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

Class static private field destructure set #12917

Merged
merged 5 commits into from Mar 3, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Feb 26, 2021

Q                       A
Fixed Issues? Runtime error is thrown when running transpiled [C.#p] = [0] (REPL)
Patch: Bug Fix? Y
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This PR depends on #12910, please review that one first.

In this PR we introduce a new helper classStaticPrivateFieldDestructureSet similar to classPrivateFieldDestructureSet except that it accepts a classRef and descriptor. From this perspective this PR can be considered the static flavor of #10017.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Class Fields Spec: Private Methods labels Feb 26, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Feb 26, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 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 c5e03f9:

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

@@ -0,0 +1,29 @@
expect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Did you mix PRs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

packages/babel-helpers/src/helpers.js Outdated Show resolved Hide resolved
@@ -0,0 +1,9 @@
class A {
run() {
babelHelpers.classStaticPrivateMethodSet(A, A, _method, 2);
Copy link
Member

Choose a reason for hiding this comment

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

In a followup, we need to make this better. We're passing _method where we expect descriptor.

Copy link
Member

Choose a reason for hiding this comment

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

In Babel 8 I'd like to just remove the concept of descriptors for private elements.
I introduced them for decorators, but the decorators proposal has evolved to be more static and now we don't need runtime descriptors anymore.

@JLHwung JLHwung force-pushed the classStaticPrivateFieldDestructureSet branch from 4dcd489 to 3910050 Compare February 26, 2021 22:36
nicolo-ribaudo
nicolo-ribaudo previously approved these changes Feb 27, 2021
@nicolo-ribaudo
Copy link
Member

Do not merge until #12910 is merged.

@JLHwung JLHwung force-pushed the classStaticPrivateFieldDestructureSet branch from 9db2859 to 4eef5ce Compare March 3, 2021 16:51
@JLHwung JLHwung force-pushed the classStaticPrivateFieldDestructureSet branch from 4eef5ce to c5e03f9 Compare March 3, 2021 20:07
@JLHwung JLHwung dismissed nicolo-ribaudo’s stale review March 3, 2021 20:48

Pending Nicolò's review on helper refactors

@@ -1299,24 +1299,90 @@ helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
`;

helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to bump the version because it's functionally equivalent, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Refactoring internals helpers should not bump minimal required helper version as long as the interface is not changed.

@JLHwung JLHwung merged commit bdb207c into babel:main Mar 3, 2021
@JLHwung JLHwung deleted the classStaticPrivateFieldDestructureSet branch March 3, 2021 21:38
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Mar 7, 2021
nicolo-ribaudo added a commit that referenced this pull request Mar 7, 2021
This was referenced Mar 17, 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 Jun 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 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: Class Fields Spec: Private Methods
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants