mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Merge pull request #21216 from Microsoft/fix19103
Fix incorrect parenthesization logic for conditional expression branches
This commit is contained in:
@@ -3960,7 +3960,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