mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix incorrect parenthesization logic for conditional expression branches
This commit is contained in:
@@ -3954,7 +3954,9 @@ namespace ts {
|
||||
// per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions
|
||||
// so in case when comma expression is introduced as a part of previous transformations
|
||||
// if should be wrapped in parens since comma operator has the lowest precedence
|
||||
return e.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>e).operatorToken.kind === SyntaxKind.CommaToken
|
||||
const emittedExpression = skipPartiallyEmittedExpressions(e);
|
||||
return emittedExpression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>emittedExpression).operatorToken.kind === SyntaxKind.CommaToken ||
|
||||
emittedExpression.kind === SyntaxKind.CommaListExpression
|
||||
? createParen(e)
|
||||
: e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user