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

TypeScript: Support a TS 3.9 breaking change for Optional Chaining and Non-Null Assertions #8450

Merged
merged 3 commits into from May 31, 2020

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented May 28, 2020

Fixes #8339

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

Try the playground for this PR

@fisker fisker mentioned this pull request May 29, 2020
4 tasks
@@ -626,6 +626,14 @@ function needsParens(path, options) {

case "OptionalMemberExpression":
case "OptionalCallExpression":
if (
node.type === "OptionalMemberExpression" &&
Copy link
Member

Choose a reason for hiding this comment

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

OptionalCallExpression should be handled too.

if (
node.type === "OptionalMemberExpression" &&
parent.type === "TSNonNullExpression" &&
path.getParentNode(1).type === "MemberExpression"
Copy link
Member

Choose a reason for hiding this comment

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

Member expressions have two child nodes, so it's not enough to check only type here.

Copy link
Member

Choose a reason for hiding this comment

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

This?

(a?.b)![a?.b!]

Copy link
Member

Choose a reason for hiding this comment

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

yep

@sosukesuzuki sosukesuzuki merged commit 3fc7579 into prettier:master May 31, 2020
@sosukesuzuki sosukesuzuki deleted the 8339 branch May 31, 2020 00:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2021
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.

Parenthesized non-null assertion in an optional chain
3 participants