createExportAssignment: parenthesize nested class or function expression

Fixes: #25222
This commit is contained in:
Klaus Meinhardt
2018-06-30 21:53:34 +02:00
parent a1746d4cfe
commit bfdb1cc391
+10 -6
View File
@@ -4185,12 +4185,16 @@ namespace ts {
*/
export function parenthesizeDefaultExpression(e: Expression) {
const check = skipPartiallyEmittedExpressions(e);
return (check.kind === SyntaxKind.ClassExpression ||
check.kind === SyntaxKind.FunctionExpression ||
check.kind === SyntaxKind.CommaListExpression ||
isBinaryExpression(check) && check.operatorToken.kind === SyntaxKind.CommaToken)
? createParen(e)
: e;
let needsParens = check.kind === SyntaxKind.CommaListExpression ||
isBinaryExpression(check) && check.operatorToken.kind === SyntaxKind.CommaToken;
if (!needsParens) {
switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) {
case SyntaxKind.ClassExpression:
case SyntaxKind.FunctionExpression:
needsParens = true;
}
}
return needsParens ? createParen(e) : e;
}
/**