Wrap parens around anonymous classes if first in statement
This commit is contained in:
parent
c20bb99a62
commit
d440e8c316
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user