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
Support destructuring private proposal #12276
Conversation
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. |
How this line affect? prettier/src/language-js/print/assignment.js Line 378 in 34fbd09
|
console.log(x); // => 1 | ||
} | ||
equals({ #x: otherX }) { | ||
const { #x: currentX } = this; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, valid. tc39/proposal-destructuring-private#3 (comment)
There was a problem hiding this comment.
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.
I prefer to separate changelog so I'll create new PR that adds changelog for the proposal unicode set notation. |
This line only affects the RHS (only nodes in inner of |
* Enable `destructuringPrivate` plugiin * Add tests * Add changelog * Add more tests
* Enable `destructuringPrivate` plugiin * Add tests * Add changelog * Add more tests
* Enable `destructuringPrivate` plugiin * Add tests * Add changelog * Add more tests
* Enable `destructuringPrivate` plugiin * Add tests * Add changelog * Add more tests
Description
Just enables
destructuringPrivate
plugin and adds tests.Partial of #12255
Checklist
changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨