Skip to content

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

Merged
sosukesuzuki merged 3 commits intoprettier:masterfrom
sosukesuzuki:8339
May 31, 2020
Merged

TypeScript: Support a TS 3.9 breaking change for Optional Chaining and Non-Null Assertions#8450
sosukesuzuki merged 3 commits intoprettier:masterfrom
sosukesuzuki:8339

Conversation

@sosukesuzuki
Copy link
Copy Markdown
Contributor

@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
case "OptionalMemberExpression":
case "OptionalCallExpression":
if (
node.type === "OptionalMemberExpression" &&
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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