return only constructor if class was a named class with only a constructor/no constructor

This commit is contained in:
Sebastian McKenzie
2015-03-07 01:50:34 +11:00
parent f801772fc2
commit 2b95b876e1
17 changed files with 58 additions and 119 deletions

View File

@@ -143,9 +143,12 @@ class ClassTransformer {
this.buildBody();
// infer class name if this is a nameless class expression
if (!this.className) {
if (this.className) {
// named class with only a constructor
if (body.length === 1) return t.toExpression(body[0]);
} else {
// infer class name if this is a nameless class expression
constructor = nameMethod.bare(constructor, this.parent, this.scope);
body.unshift(t.variableDeclaration("var", [