@@ -272,10 +272,9 @@ namespace ts {
272
272
}
273
273
274
274
function parenthesizeForComputedName ( expression : Expression ) : Expression {
275
- return ( isBinaryExpression ( expression ) && expression . operatorToken . kind === SyntaxKind . CommaToken ) ||
276
- expression . kind === SyntaxKind . CommaListExpression ?
277
- createParen ( expression ) :
278
- expression ;
275
+ return isCommaSequence ( expression )
276
+ ? createParen ( expression )
277
+ : expression ;
279
278
}
280
279
281
280
export function createComputedPropertyName ( expression : Expression ) {
@@ -4166,8 +4165,7 @@ namespace ts {
4166
4165
// so in case when comma expression is introduced as a part of previous transformations
4167
4166
// if should be wrapped in parens since comma operator has the lowest precedence
4168
4167
const emittedExpression = skipPartiallyEmittedExpressions ( e ) ;
4169
- return emittedExpression . kind === SyntaxKind . BinaryExpression && ( < BinaryExpression > emittedExpression ) . operatorToken . kind === SyntaxKind . CommaToken ||
4170
- emittedExpression . kind === SyntaxKind . CommaListExpression
4168
+ return isCommaSequence ( emittedExpression )
4171
4169
? createParen ( e )
4172
4170
: e ;
4173
4171
}
@@ -4185,10 +4183,9 @@ namespace ts {
4185
4183
*/
4186
4184
export function parenthesizeDefaultExpression ( e : Expression ) {
4187
4185
const check = skipPartiallyEmittedExpressions ( e ) ;
4188
- return ( check . kind === SyntaxKind . ClassExpression ||
4186
+ return check . kind === SyntaxKind . ClassExpression ||
4189
4187
check . kind === SyntaxKind . FunctionExpression ||
4190
- check . kind === SyntaxKind . CommaListExpression ||
4191
- isBinaryExpression ( check ) && check . operatorToken . kind === SyntaxKind . CommaToken )
4188
+ isCommaSequence ( check )
4192
4189
? createParen ( e )
4193
4190
: e ;
4194
4191
}
@@ -4374,13 +4371,18 @@ namespace ts {
4374
4371
}
4375
4372
4376
4373
export function parenthesizeConciseBody ( body : ConciseBody ) : ConciseBody {
4377
- if ( ! isBlock ( body ) && getLeftmostExpression ( body , /*stopAtCallExpressions*/ false ) . kind === SyntaxKind . ObjectLiteralExpression ) {
4374
+ if ( ! isBlock ( body ) && ( isCommaSequence ( body ) || getLeftmostExpression ( body , /*stopAtCallExpressions*/ false ) . kind === SyntaxKind . ObjectLiteralExpression ) ) {
4378
4375
return setTextRange ( createParen ( body ) , body ) ;
4379
4376
}
4380
4377
4381
4378
return body ;
4382
4379
}
4383
4380
4381
+ export function isCommaSequence ( node : Expression ) : node is BinaryExpression & { operatorToken : Token < SyntaxKind . CommaToken > } | CommaListExpression {
4382
+ return node . kind === SyntaxKind . BinaryExpression && ( < BinaryExpression > node ) . operatorToken . kind === SyntaxKind . CommaToken ||
4383
+ node . kind === SyntaxKind . CommaListExpression ;
4384
+ }
4385
+
4384
4386
export const enum OuterExpressionKinds {
4385
4387
Parentheses = 1 << 0 ,
4386
4388
Assertions = 1 << 1 ,
0 commit comments