Merge pull request #25341 from ajafff/factory-export-default

createExportAssignment: parenthesize nested class or function expression
This commit is contained in:
Mohamed Hegazy
2018-07-06 10:33:34 -07:00
committed by GitHub
2 changed files with 36 additions and 5 deletions

View File

@@ -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;
}
/**