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

Unify parens printing for postfix-like expressions #11382

Merged
merged 4 commits into from Apr 7, 2020

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues? repl
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This blocks #10961

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: generator area: typescript labels Apr 5, 2020
@@ -32,6 +32,15 @@ const isClassExtendsClause = (node: Object, parent: Object): boolean =>
(t.isClassDeclaration(parent) || t.isClassExpression(parent)) &&
parent.superClass === node;

const isPostfixExpression = (node: Object, parent: Object) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK the postfix expression is used to describe a way of how the operator and its operands are arranged, so I am confused about the term here.

The Spec provides a term LeftHandSideExpression and I think we can stick with that.

Copy link
Member Author

Choose a reason for hiding this comment

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

LeftHandSideExpression doesn't work, because it also covers PrimaryExpression.

I initially called this "postfix" because TS's ! is a postfix operator, and because in foo() and foo.bar, () and .bar are "postfixes" of the main foo expression 😅

Maybe hasPostfixPart?

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with hasPostfixPart.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good for me 🌝

@nicolo-ribaudo nicolo-ribaudo changed the title Unify parens printing for postfix exprs: (), [...], ! Unify parens printing for ...(), ...[0], ...! and template tags Apr 7, 2020
@nicolo-ribaudo nicolo-ribaudo changed the title Unify parens printing for ...(), ...[0], ...! and template tags Unify parens printing for postfix-like expressions Apr 7, 2020
@nicolo-ribaudo nicolo-ribaudo merged commit ce6cc4e into babel:master Apr 7, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the ts-nonnull-parens branch April 7, 2020 19:36
@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 Jul 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants