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

Refactor bindingProperty parsing #13929

Merged
merged 8 commits into from Nov 12, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Nov 4, 2021

Q                       A
Fixed Issues? See comments below
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

The PR is extracted from my local working branch on destructuring private parsing.

  • The parseMaybePrivateName is inlined to parsePropertyName
  • The parseBindingProperty is extracted from parsePropertyDefinition
  • The private name in class (common scenario) is now handled in parseClassElementName, since we already checked privateName to throw private constructor error. The parsePropertyName now always throws private name in object. In the future it will handle the ambiguous ({ #x: x }).

Two bugs are fixed during refactoring.

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories area: flow pkg: parser Spec: Decorators (Legacy) labels Nov 4, 2021
@@ -0,0 +1 @@
var { @foo foo } = foo;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current main incorrectly allows decorators in pattern. This is now fixed, by not handling decorators at all in parseBindingProperty.

class A {
+#foo;
-#foo;
}
Copy link
Contributor Author

@JLHwung JLHwung Nov 4, 2021

Choose a reason for hiding this comment

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

The current main incorrectly parses +#foo as ClassProperty instead of ClassPrivateProperty. This is now fixed by a new parsePropertyNamePrefixOperator hook for the Flow plugin.

@babel-bot
Copy link
Collaborator

babel-bot commented Nov 4, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 4, 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 2efdbf8:

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

@@ -1,3 +1,3 @@
class C {
#p = ({ #x: 42 });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is renamed to invalid-object-property/input.js.

@JLHwung JLHwung force-pushed the split-parse-property-definition branch from fafff94 to 647ecd4 Compare November 4, 2021 18:11
@JLHwung JLHwung force-pushed the split-parse-property-definition branch from a28cfbc to 2efdbf8 Compare November 4, 2021 18:49
@JLHwung JLHwung mentioned this pull request Nov 5, 2021
4 tasks
@JLHwung JLHwung merged commit 54c539e into babel:main Nov 12, 2021
@JLHwung JLHwung deleted the split-parse-property-definition branch November 12, 2021 15:11
@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 Feb 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: flow outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Decorators (Legacy)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants