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
Conversation
src/language-js/needs-parens.js
Outdated
@@ -626,6 +626,14 @@ function needsParens(path, options) { | |||
|
|||
case "OptionalMemberExpression": | |||
case "OptionalCallExpression": | |||
if ( | |||
node.type === "OptionalMemberExpression" && |
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.
OptionalCallExpression
should be handled too.
src/language-js/needs-parens.js
Outdated
if ( | ||
node.type === "OptionalMemberExpression" && | ||
parent.type === "TSNonNullExpression" && | ||
path.getParentNode(1).type === "MemberExpression" |
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.
Member expressions have two child nodes, so it's not enough to check only type
here.
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.
This?
(a?.b)![a?.b!]
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.
yep
Fixes #8339
changelog_unreleased/*/pr-XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.