return only constructor if class was a named class with only a constructor/no constructor
This commit is contained in:
parent
f801772fc2
commit
2b95b876e1
@ -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", [
|
||||
|
||||
@ -2,12 +2,8 @@
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
var Test = function Test() {
|
||||
_classCallCheck(this, Test);
|
||||
|
||||
arr.map(x => x * x);
|
||||
}
|
||||
|
||||
return Test;
|
||||
})();
|
||||
arr.map(x => x * x);
|
||||
};
|
||||
@ -1,11 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
Function.prototype.hasOwnProperty.call(this, "test");
|
||||
}
|
||||
|
||||
return Test;
|
||||
})();
|
||||
Function.prototype.hasOwnProperty.call(this, "test");
|
||||
};
|
||||
@ -1,14 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
this.state = "test";
|
||||
}
|
||||
|
||||
return Test;
|
||||
})();
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
var Foo = (function (_Bar) {
|
||||
function Foo() {
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
return Test;
|
||||
})();
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
};
|
||||
@ -1,14 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var BaseView = (function () {
|
||||
function BaseView() {
|
||||
babelHelpers.classCallCheck(this, BaseView);
|
||||
var BaseView = function BaseView() {
|
||||
babelHelpers.classCallCheck(this, BaseView);
|
||||
|
||||
this.autoRender = true;
|
||||
}
|
||||
|
||||
return BaseView;
|
||||
})();
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
var BaseView = (function () {
|
||||
var _class = function BaseView() {
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
||||
}
|
||||
|
||||
return Test;
|
||||
})();
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
||||
};
|
||||
@ -23,13 +23,9 @@ define(["exports", "module"], function (exports, module) {
|
||||
|
||||
function foo() {}
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
});
|
||||
@ -15,13 +15,9 @@ define(["exports"], function (exports) {
|
||||
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = exports.foo8 = (function () {
|
||||
function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
}
|
||||
|
||||
return foo8;
|
||||
})();
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
|
||||
@ -22,12 +22,8 @@ module.exports = _default;
|
||||
|
||||
function foo() {}
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
@ -14,13 +14,9 @@ var foo6 = exports.foo6 = 3;
|
||||
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = exports.foo8 = (function () {
|
||||
function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
}
|
||||
|
||||
return foo8;
|
||||
})();
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
|
||||
@ -12,10 +12,6 @@ var _default = (function () {
|
||||
|
||||
function foo() {}
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
@ -13,10 +13,6 @@ var foo6 = 3;
|
||||
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = (function () {
|
||||
function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
}
|
||||
|
||||
return foo8;
|
||||
})();
|
||||
var foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
@ -32,13 +32,9 @@ System.register([], function (_export) {
|
||||
|
||||
_export("default", _default);
|
||||
|
||||
Foo = (function () {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
_export("default", Foo);
|
||||
}
|
||||
|
||||
@ -18,13 +18,9 @@ System.register([], function (_export) {
|
||||
foo4 = _export("foo4", 2);
|
||||
foo5 = _export("foo5", undefined);
|
||||
foo6 = _export("foo6", 3);
|
||||
foo8 = _export("foo8", (function () {
|
||||
function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
}
|
||||
|
||||
return foo8;
|
||||
})());
|
||||
foo8 = _export("foo8", function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
});
|
||||
|
||||
_export("foo3", foo3 = 5);
|
||||
}
|
||||
|
||||
@ -29,13 +29,9 @@
|
||||
|
||||
function foo() {}
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
var Foo = function Foo() {
|
||||
_classCallCheck(this, Foo);
|
||||
};
|
||||
|
||||
module.exports = Foo;
|
||||
});
|
||||
@ -21,13 +21,9 @@
|
||||
|
||||
function foo7() {}
|
||||
|
||||
var foo8 = exports.foo8 = (function () {
|
||||
function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
}
|
||||
|
||||
return foo8;
|
||||
})();
|
||||
var foo8 = exports.foo8 = function foo8() {
|
||||
_classCallCheck(this, foo8);
|
||||
};
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user