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

Support destructuring private proposal #12276

Merged

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Feb 12, 2022

Description

Just enables destructuringPrivate plugin and adds tests.

Partial of #12255

Checklist

  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker
Copy link
Sponsor Member

fisker commented Feb 12, 2022

Can you mention that we support this https://github.com/tc39/proposal-regexp-set-notation/ in changelog? I forgot to add changelog in #12241, unless you want add seperate changelog for it.

@fisker
Copy link
Sponsor Member

fisker commented Feb 12, 2022

How this line affect?

const threshold = printWidth * LONE_SHORT_ARGUMENT_THRESHOLD_RATE;

console.log(x); // => 1
}
equals({ #x: otherX }) {
const { #x: currentX } = this;
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Is assign allowed in this syntax?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. This example is copied from the example of https://github.com/tc39/proposal-destructuring-private.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

({ #x: variable.or.property.to.assign } = this);

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah sorry I misunderstood. Destructuring private in assign expression is maybe invalid. No, I don't know. I'll look into it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@fisker Maybe this is valid. So what should we do for it?

Copy link
Sponsor Member

@fisker fisker Feb 13, 2022

Choose a reason for hiding this comment

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

Seems working fine,

Prettier pr-12276
Playground link

--parser babel

Input:

class A {
  
  method() {
    ({ #x: variable.or.property.to.assign } = this);
    }
}

Output:

class A {
  method() {
    ({ #x: variable.or.property.to.assign } = this);
  }
}

Add a test for it, and check if we need adjust the printer.

This syntax is a good one, I was waiting for it for quite a while, I may actual use it.

Copy link
Sponsor Member

@fisker fisker Feb 13, 2022

Choose a reason for hiding this comment

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

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Don't forget add some tests for destructuring with default value.

@sosukesuzuki
Copy link
Member Author

Can you mention that we support this https://github.com/tc39/proposal-regexp-set-notation/ in changelog? I forgot to add changelog in #12241, unless you want add seperate changelog for it.

I prefer to separate changelog so I'll create new PR that adds changelog for the proposal unicode set notation.

@sosukesuzuki
Copy link
Member Author

How this line affect?

This line only affects the RHS (only nodes in inner of CallExpression) of the assignment, so I don't think it is relevant to the syntax of Destructuring Private. ({ #foo: foo } can appear on only LHS.)

@sosukesuzuki sosukesuzuki merged commit 8c49fd0 into prettier:main Feb 14, 2022
@sosukesuzuki sosukesuzuki deleted the support-destructuring-private branch February 14, 2022 02:28
nevilm-lt pushed a commit to nevilm-lt/prettier that referenced this pull request Mar 14, 2022
* Enable `destructuringPrivate` plugiin

* Add tests

* Add changelog

* Add more tests
nevilm-lt pushed a commit to nevilm-lt/prettier that referenced this pull request Apr 21, 2022
* Enable `destructuringPrivate` plugiin

* Add tests

* Add changelog

* Add more tests
nevilm-lt pushed a commit to nevilm-lt/prettier that referenced this pull request Apr 21, 2022
* Enable `destructuringPrivate` plugiin

* Add tests

* Add changelog

* Add more tests
nevilm-lt pushed a commit to nevilm-lt/prettier that referenced this pull request Apr 22, 2022
* Enable `destructuringPrivate` plugiin

* Add tests

* Add changelog

* Add more tests
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants