add name to constructor of extended anonymous class
This commit is contained in:
@@ -83,7 +83,14 @@ ClassTransformer.prototype.run = function () {
|
||||
constructor = t.functionDeclaration(className, [], constructorBody);
|
||||
body.push(constructor);
|
||||
} else {
|
||||
constructor = t.functionExpression(null, [], constructorBody);
|
||||
var constructorName = null;
|
||||
// when there is only constructor or nothing, constructor is not
|
||||
// wrapped in closure and has to be named
|
||||
if (this.node.body.body.length <= 1) {
|
||||
constructorName = className;
|
||||
}
|
||||
|
||||
constructor = t.functionExpression(constructorName, [], constructorBody);
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(className, constructor)
|
||||
]));
|
||||
|
||||
Reference in New Issue
Block a user