Skip to content

Commit 4f671ff

Browse files
committed
tbaf: don't parentheses when or's are inside
1 parent 73e3a13 commit 4f671ff

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

server/src/tbaf.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,15 @@ function canRemoveParentheses(node: ParenthesizedExpression): boolean {
758758

759759
const innerExpression = node.getExpression();
760760

761-
// Remove parentheses safely only if the parent allows it
761+
// If the immediate inner expression is a binary expression with `||`, skip removal
762+
if (
763+
innerExpression.isKind(SyntaxKind.BinaryExpression) &&
764+
(innerExpression as BinaryExpression).getOperatorToken().getText() === "||"
765+
) {
766+
return false;
767+
}
768+
769+
// Allow removal in safe contexts
762770
if (
763771
parent.isKind(SyntaxKind.BinaryExpression) ||
764772
parent.isKind(SyntaxKind.IfStatement) ||
@@ -773,6 +781,7 @@ function canRemoveParentheses(node: ParenthesizedExpression): boolean {
773781

774782

775783

784+
776785
/**
777786
* Apply the transformations. Progressize inlining and unrolling, then else inversion and if flattening.
778787
*/

0 commit comments

Comments
 (0)