clean up #870
This commit is contained in:
parent
8c5e7cf272
commit
717ef280f7
@ -78,19 +78,17 @@ ClassTransformer.prototype.run = function () {
|
|||||||
className
|
className
|
||||||
]))
|
]))
|
||||||
]);
|
]);
|
||||||
var constructor;
|
|
||||||
|
|
||||||
|
var constructor;
|
||||||
if (this.node.id) {
|
if (this.node.id) {
|
||||||
constructor = t.functionDeclaration(className, [], constructorBody);
|
constructor = t.functionDeclaration(className, [], constructorBody);
|
||||||
body.push(constructor);
|
body.push(constructor);
|
||||||
} else {
|
} else {
|
||||||
var constructorName = null;
|
var constructorName = null;
|
||||||
// when class has no parent and there is only constructor or nothing then
|
// when a class has no parent and there is only a constructor or no body
|
||||||
// constructor is not wrapped in closure and has to be named
|
// then the constructor is not wrapped in a closure and needs to be named
|
||||||
var containsOnlyConstructor = classBody.length === 1 &&
|
var containsOnlyConstructor = classBody.length === 1 && classBody[0].key.name === "constructor";
|
||||||
classBody[0].key.name === "constructor";
|
if (!this.hasSuper && (classBody.length === 0 || containsOnlyConstructor)) {
|
||||||
if (!this.hasSuper && (classBody.length === 0 ||
|
|
||||||
containsOnlyConstructor)) {
|
|
||||||
constructorName = className;
|
constructorName = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user