Wrap parens around anonymous classes if first in statement

This commit is contained in:
Anthony Van de Gejuchte 2017-04-04 10:30:18 +02:00
parent c20bb99a62
commit d440e8c316
2 changed files with 20 additions and 0 deletions

View File

@ -629,6 +629,15 @@ function OutputStream(options) {
return false; return false;
}); });
// Anonymous classes needs parens around when it's the first token in a statement.
PARENS(AST_Class, function(output){
if (this.name === undefined && first_in_statement(output)) {
return true;
}
return false;
});
PARENS(AST_Arrow, function(output){ PARENS(AST_Arrow, function(output){
var p = output.parent(); var p = output.parent();
return p instanceof AST_PropAccess && p.expression === this; return p instanceof AST_PropAccess && p.expression === this;

View File

@ -159,6 +159,17 @@ classes_with_expression_as_expand: {
expect_exact: "class D extends(calls++,C){}" expect_exact: "class D extends(calls++,C){}"
} }
class_as_sequence_expression: {
options = {
side_effects: true
}
input: {
0, class {}
0, class A{}
}
expect_exact: "(class{});class A{};"
}
new_target: { new_target: {
input: { input: {
new.target; new.target;