mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Merge pull request #25341 from ajafff/factory-export-default
createExportAssignment: parenthesize nested class or function expression
This commit is contained in:
@@ -4183,11 +4183,15 @@ namespace ts {
|
||||
*/
|
||||
export function parenthesizeDefaultExpression(e: Expression) {
|
||||
const check = skipPartiallyEmittedExpressions(e);
|
||||
return check.kind === SyntaxKind.ClassExpression ||
|
||||
check.kind === SyntaxKind.FunctionExpression ||
|
||||
isCommaSequence(check)
|
||||
? createParen(e)
|
||||
: e;
|
||||
let needsParens = isCommaSequence(check);
|
||||
if (!needsParens) {
|
||||
switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) {
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
needsParens = true;
|
||||
}
|
||||
}
|
||||
return needsParens ? createParen(e) : e;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user