Fix some missing parens cases with OptionalMemberExpression in generator (#8751)
This commit is contained in:
@@ -209,6 +209,7 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
|
||||
t.isBinary(parent) ||
|
||||
t.isConditionalExpression(parent, { test: node }) ||
|
||||
t.isAwaitExpression(parent) ||
|
||||
t.isOptionalMemberExpression(parent) ||
|
||||
t.isTaggedTemplateExpression(parent) ||
|
||||
t.isTSTypeAssertion(parent) ||
|
||||
t.isTSAsExpression(parent)
|
||||
@@ -219,6 +220,13 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
|
||||
export function OptionalMemberExpression(
|
||||
node: Object,
|
||||
parent: Object,
|
||||
): boolean {
|
||||
return t.isCallExpression(parent) || t.isMemberExpression(parent);
|
||||
}
|
||||
|
||||
export function AssignmentExpression(node: Object): boolean {
|
||||
if (t.isObjectPattern(node.left)) {
|
||||
return true;
|
||||
|
||||
@@ -14,3 +14,7 @@ foo?.["bar"]?.foo;
|
||||
0.?.toString();
|
||||
0.5?.toString();
|
||||
1.000?.toString();
|
||||
|
||||
(a?.b).c;
|
||||
(a ? b : c)?.d;
|
||||
(a?.b)()
|
||||
|
||||
@@ -11,4 +11,7 @@ foo?.["bar"].foo;
|
||||
foo?.["bar"]?.foo;
|
||||
0.?.toString();
|
||||
0.5?.toString();
|
||||
1.000?.toString();
|
||||
1.000?.toString();
|
||||
(a?.b).c;
|
||||
(a ? b : c)?.d;
|
||||
(a?.b)();
|
||||
Reference in New Issue
Block a user