Skip to content

Class static private field destructure set#12917

Merged
JLHwung merged 5 commits intobabel:mainfrom
JLHwung:classStaticPrivateFieldDestructureSet
Mar 3, 2021
Merged

Class static private field destructure set#12917
JLHwung merged 5 commits intobabel:mainfrom
JLHwung:classStaticPrivateFieldDestructureSet

Conversation

@JLHwung
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread packages/babel-helpers/src/helpers.js Outdated
@@ -0,0 +1,9 @@
class A {
run() {
babelHelpers.classStaticPrivateMethodSet(A, A, _method, 2);
Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread Makefile
nicolo-ribaudo
nicolo-ribaudo previously approved these changes Feb 27, 2021
@nicolo-ribaudo
Copy link
Copy Markdown
Member

Do not merge until #12910 is merged.

@nicolo-ribaudo nicolo-ribaudo self-requested a review February 27, 2021 15:50
@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
Copy Markdown
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
Copy Markdown
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.

4 participants