File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -4185,12 +4185,16 @@ namespace ts {
4185
4185
*/
4186
4186
export function parenthesizeDefaultExpression ( e : Expression ) {
4187
4187
const check = skipPartiallyEmittedExpressions ( e ) ;
4188
- return ( check . kind === SyntaxKind . ClassExpression ||
4189
- check . kind === SyntaxKind . FunctionExpression ||
4190
- check . kind === SyntaxKind . CommaListExpression ||
4191
- isBinaryExpression ( check ) && check . operatorToken . kind === SyntaxKind . CommaToken )
4192
- ? createParen ( e )
4193
- : e ;
4188
+ let needsParens = check . kind === SyntaxKind . CommaListExpression ||
4189
+ isBinaryExpression ( check ) && check . operatorToken . kind === SyntaxKind . CommaToken ;
4190
+ if ( ! needsParens ) {
4191
+ switch ( getLeftmostExpression ( check , /*stopAtCallExpression*/ false ) . kind ) {
4192
+ case SyntaxKind . ClassExpression :
4193
+ case SyntaxKind . FunctionExpression :
4194
+ needsParens = true ;
4195
+ }
4196
+ }
4197
+ return needsParens ? createParen ( e ) : e ;
4194
4198
}
4195
4199
4196
4200
/**
You can’t perform that action at this time.
0 commit comments