this before super() is a runtime error, not a static one. (#6467)
* Check that super.* is after super() at runtime * "missing super() call in constructor" runtime * "'this' is not allowed before super()" runtime
This commit is contained in:
parent
e270fbe7f0
commit
509dbb7302
@ -106,6 +106,7 @@ export default class ReplaceSupers {
|
|||||||
this.isStatic = opts.isStatic;
|
this.isStatic = opts.isStatic;
|
||||||
this.hasSuper = false;
|
this.hasSuper = false;
|
||||||
this.inClass = inClass;
|
this.inClass = inClass;
|
||||||
|
this.inConstructor = opts.inConstructor;
|
||||||
this.isLoose = opts.isLoose;
|
this.isLoose = opts.isLoose;
|
||||||
this.scope = this.methodPath.scope;
|
this.scope = this.methodPath.scope;
|
||||||
this.file = opts.file;
|
this.file = opts.file;
|
||||||
@ -123,6 +124,7 @@ export default class ReplaceSupers {
|
|||||||
isStatic: boolean;
|
isStatic: boolean;
|
||||||
hasSuper: boolean;
|
hasSuper: boolean;
|
||||||
inClass: boolean;
|
inClass: boolean;
|
||||||
|
inConstructor: boolean;
|
||||||
isLoose: boolean;
|
isLoose: boolean;
|
||||||
scope: Scope;
|
scope: Scope;
|
||||||
file;
|
file;
|
||||||
@ -132,6 +134,7 @@ export default class ReplaceSupers {
|
|||||||
methodPath: NodePath,
|
methodPath: NodePath,
|
||||||
methodNode: Object,
|
methodNode: Object,
|
||||||
superRef: Object,
|
superRef: Object,
|
||||||
|
inConstructor: boolean,
|
||||||
isStatic: boolean,
|
isStatic: boolean,
|
||||||
isLoose: boolean,
|
isLoose: boolean,
|
||||||
file: any,
|
file: any,
|
||||||
@ -174,10 +177,18 @@ export default class ReplaceSupers {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
getSuperProperty(property: Object, isComputed: boolean): Object {
|
getSuperProperty(property: Object, isComputed: boolean): Object {
|
||||||
|
let thisExpr = t.thisExpression();
|
||||||
|
if (this.inConstructor) {
|
||||||
|
thisExpr = t.callExpression(
|
||||||
|
this.file.addHelper("assertThisInitialized"),
|
||||||
|
[thisExpr],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return t.callExpression(this.file.addHelper("get"), [
|
return t.callExpression(this.file.addHelper("get"), [
|
||||||
getPrototypeOfExpression(this.getObjectRef(), this.isStatic),
|
getPrototypeOfExpression(this.getObjectRef(), this.isStatic),
|
||||||
isComputed ? property : t.stringLiteral(property.name),
|
isComputed ? property : t.stringLiteral(property.name),
|
||||||
t.thisExpression(),
|
thisExpr,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -509,12 +509,24 @@ helpers.objectWithoutProperties = defineHelper(`
|
|||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
helpers.assertThisInitialized = defineHelper(`
|
||||||
|
export default function _assertThisInitialized(self) {
|
||||||
|
if (self === void 0) {
|
||||||
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
|
||||||
helpers.possibleConstructorReturn = defineHelper(`
|
helpers.possibleConstructorReturn = defineHelper(`
|
||||||
export default function _possibleConstructorReturn(self, call) {
|
export default function _possibleConstructorReturn(self, call) {
|
||||||
if (call && (typeof call === "object" || typeof call === "function")) {
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
if (!self) {
|
// TODO: Should just be
|
||||||
|
// import assertThisInitialized from "assertThisInitialized";
|
||||||
|
// return assertThisInitialized(self);
|
||||||
|
if (self === void 0) {
|
||||||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ function (_Bar) {
|
|||||||
var _temp, _this;
|
var _temp, _this;
|
||||||
|
|
||||||
babelHelpers.classCallCheck(this, Foo);
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, ...args)), Object.defineProperty(_this, "bar", {
|
return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ function (_Parent) {
|
|||||||
|
|
||||||
babelHelpers.classCallCheck(this, Child);
|
babelHelpers.classCallCheck(this, Child);
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this));
|
||||||
Object.defineProperty(_this, "scopedFunctionWithThis", {
|
Object.defineProperty(babelHelpers.assertThisInitialized(_this), "scopedFunctionWithThis", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
@ -23,11 +23,11 @@ function (_A) {
|
|||||||
var _temp, _this;
|
var _temp, _this;
|
||||||
|
|
||||||
babelHelpers.classCallCheck(this, B);
|
babelHelpers.classCallCheck(this, B);
|
||||||
return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this, ...args)), Object.defineProperty(_this, "foo", {
|
return babelHelpers.possibleConstructorReturn(_this, (_temp = _this = babelHelpers.possibleConstructorReturn(this, (B.__proto__ || Object.getPrototypeOf(B)).call(this, ...args)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "foo", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
value: babelHelpers.get(B.prototype.__proto__ || Object.getPrototypeOf(B.prototype), "foo", _this).call(_this)
|
value: babelHelpers.get(B.prototype.__proto__ || Object.getPrototypeOf(B.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this)
|
||||||
}), _temp));
|
}), _temp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ function (_Bar) {
|
|||||||
var _temp, _this;
|
var _temp, _this;
|
||||||
|
|
||||||
babelHelpers.classCallCheck(this, Foo);
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)), Object.defineProperty(_this, "bar", {
|
foo((_temp = _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)), Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ function (_Bar) {
|
|||||||
|
|
||||||
babelHelpers.classCallCheck(this, Foo);
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
Object.defineProperty(_this, "bar", {
|
Object.defineProperty(babelHelpers.assertThisInitialized(_this), "bar", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|||||||
|
|
||||||
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
|
function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } }
|
||||||
|
|
||||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
@ -10,6 +10,8 @@ function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Con
|
|||||||
|
|
||||||
function _get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return _get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }
|
function _get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return _get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }
|
||||||
|
|
||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
var Test = function Test() {
|
var Test = function Test() {
|
||||||
var _this2 = this;
|
var _this2 = this;
|
||||||
|
|
||||||
@ -31,12 +33,12 @@ var Test = function Test() {
|
|||||||
args[_key] = arguments[_key];
|
args[_key] = arguments[_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = Other.__proto__ || Object.getPrototypeOf(Other)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_this, "a", {
|
return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = Other.__proto__ || Object.getPrototypeOf(Other)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "a", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
value: function value() {
|
value: function value() {
|
||||||
return _get(Other.prototype.__proto__ || Object.getPrototypeOf(Other.prototype), "test", _this);
|
return _get(Other.prototype.__proto__ || Object.getPrototypeOf(Other.prototype), "test", _assertThisInitialized(_this));
|
||||||
}
|
}
|
||||||
}), _temp));
|
}), _temp));
|
||||||
}
|
}
|
||||||
@ -49,7 +51,7 @@ var Test = function Test() {
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
value: function value() {
|
value: function value() {
|
||||||
return _get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this2);
|
return _get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this2));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,22 +17,6 @@ const noMethodVisitor = {
|
|||||||
const verifyConstructorVisitor = traverse.visitors.merge([
|
const verifyConstructorVisitor = traverse.visitors.merge([
|
||||||
noMethodVisitor,
|
noMethodVisitor,
|
||||||
{
|
{
|
||||||
MemberExpression: {
|
|
||||||
exit(path) {
|
|
||||||
const objectPath = path.get("object");
|
|
||||||
if (this.isDerived && !this.hasBareSuper && objectPath.isSuper()) {
|
|
||||||
const hasArrowFunctionParent = path.findParent(p =>
|
|
||||||
p.isArrowFunctionExpression(),
|
|
||||||
);
|
|
||||||
if (!hasArrowFunctionParent) {
|
|
||||||
throw objectPath.buildCodeFrameError(
|
|
||||||
"'super.*' is not allowed before super()",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
CallExpression: {
|
CallExpression: {
|
||||||
exit(path) {
|
exit(path) {
|
||||||
if (path.get("callee").isSuper()) {
|
if (path.get("callee").isSuper()) {
|
||||||
@ -48,14 +32,20 @@ const verifyConstructorVisitor = traverse.visitors.merge([
|
|||||||
},
|
},
|
||||||
|
|
||||||
ThisExpression(path) {
|
ThisExpression(path) {
|
||||||
if (this.isDerived && !this.hasBareSuper) {
|
if (this.isDerived) {
|
||||||
const fn = path.find(p => p.isFunction());
|
if (path.parentPath.isMemberExpression({ object: path.node })) {
|
||||||
|
// In cases like this.foo or this[foo], there is no need to add
|
||||||
if (!fn || !fn.isArrowFunctionExpression()) {
|
// assertThisInitialized, since they already throw if this is
|
||||||
throw path.buildCodeFrameError(
|
// undefined.
|
||||||
"'this' is not allowed before super()",
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const assertion = t.callExpression(
|
||||||
|
this.file.addHelper("assertThisInitialized"),
|
||||||
|
[path.node],
|
||||||
|
);
|
||||||
|
path.replaceWith(assertion);
|
||||||
|
path.skip();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -271,6 +261,7 @@ export default class ClassTransformer {
|
|||||||
methodNode: node,
|
methodNode: node,
|
||||||
objectRef: this.classRef,
|
objectRef: this.classRef,
|
||||||
superRef: this.superName,
|
superRef: this.superName,
|
||||||
|
inConstructor: isConstructor,
|
||||||
isStatic: node.static,
|
isStatic: node.static,
|
||||||
isLoose: this.isLoose,
|
isLoose: this.isLoose,
|
||||||
scope: this.scope,
|
scope: this.scope,
|
||||||
@ -444,10 +435,6 @@ export default class ClassTransformer {
|
|||||||
const path = this.userConstructorPath;
|
const path = this.userConstructorPath;
|
||||||
const body = path.get("body");
|
const body = path.get("body");
|
||||||
|
|
||||||
if (!this.hasBareSuper && !this.superReturns.length) {
|
|
||||||
throw path.buildCodeFrameError("missing super() call in constructor");
|
|
||||||
}
|
|
||||||
|
|
||||||
path.traverse(findThisesVisitor, this);
|
path.traverse(findThisesVisitor, this);
|
||||||
|
|
||||||
let guaranteedSuperBeforeFinish = !!this.bareSupers.length;
|
let guaranteedSuperBeforeFinish = !!this.bareSupers.length;
|
||||||
@ -469,7 +456,11 @@ export default class ClassTransformer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPath.isLoop() || parentPath.isConditional()) {
|
if (
|
||||||
|
parentPath.isLoop() ||
|
||||||
|
parentPath.isConditional() ||
|
||||||
|
parentPath.isArrowFunctionExpression()
|
||||||
|
) {
|
||||||
guaranteedSuperBeforeFinish = false;
|
guaranteedSuperBeforeFinish = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -485,9 +476,13 @@ export default class ClassTransformer {
|
|||||||
|
|
||||||
if (this.isLoose) {
|
if (this.isLoose) {
|
||||||
wrapReturn = returnArg => {
|
wrapReturn = returnArg => {
|
||||||
|
const thisExpr = t.callExpression(
|
||||||
|
this.file.addHelper("assertThisInitialized"),
|
||||||
|
[thisRef()],
|
||||||
|
);
|
||||||
return returnArg
|
return returnArg
|
||||||
? t.logicalExpression("||", returnArg, thisRef())
|
? t.logicalExpression("||", returnArg, thisExpr)
|
||||||
: thisRef();
|
: thisExpr;
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
wrapReturn = returnArg =>
|
wrapReturn = returnArg =>
|
||||||
@ -500,7 +495,7 @@ export default class ClassTransformer {
|
|||||||
// if we have a return as the last node in the body then we've already caught that
|
// if we have a return as the last node in the body then we've already caught that
|
||||||
// return
|
// return
|
||||||
const bodyPaths = body.get("body");
|
const bodyPaths = body.get("body");
|
||||||
if (bodyPaths.length && !bodyPaths.pop().isReturnStatement()) {
|
if (!bodyPaths.length || !bodyPaths.pop().isReturnStatement()) {
|
||||||
body.pushContainer(
|
body.pushContainer(
|
||||||
"body",
|
"body",
|
||||||
t.returnStatement(
|
t.returnStatement(
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
let B = function B() {};
|
let B = function B() {};
|
||||||
@ -11,7 +13,7 @@ function (_B) {
|
|||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
if (track !== undefined) _this = _B.call(this, track) || this;else _this = _B.call(this) || this;
|
if (track !== undefined) _this = _B.call(this, track) || this;else _this = _B.call(this) || this;
|
||||||
return _this;
|
return _assertThisInitialized(_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return A;
|
return A;
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inheritsLoose(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
return babelHelpers.assertThisInitialized(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "missing super() call in constructor",
|
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
|
||||||
@ -6,7 +6,7 @@ function (_Base) {
|
|||||||
function Child() {
|
function Child() {
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
return false || _this;
|
return false || babelHelpers.assertThisInitialized(_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Child;
|
return Child;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ function (_Base) {
|
|||||||
function Child() {
|
function Child() {
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
return {} || _this;
|
return {} || babelHelpers.assertThisInitialized(_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Child;
|
return Child;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ function (_b) {
|
|||||||
_this = babelHelpers.possibleConstructorReturn(this, (a1.__proto__ || Object.getPrototypeOf(a1)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (a1.__proto__ || Object.getPrototypeOf(a1)).call(this));
|
||||||
|
|
||||||
_this.x = function () {
|
_this.x = function () {
|
||||||
return _this;
|
return babelHelpers.assertThisInitialized(_this);
|
||||||
};
|
};
|
||||||
|
|
||||||
return _this;
|
return _this;
|
||||||
@ -42,7 +42,7 @@ function (_b2) {
|
|||||||
_this2 = babelHelpers.possibleConstructorReturn(this, (a2.__proto__ || Object.getPrototypeOf(a2)).call(this));
|
_this2 = babelHelpers.possibleConstructorReturn(this, (a2.__proto__ || Object.getPrototypeOf(a2)).call(this));
|
||||||
|
|
||||||
_this2.x = function () {
|
_this2.x = function () {
|
||||||
return _this2;
|
return babelHelpers.assertThisInitialized(_this2);
|
||||||
};
|
};
|
||||||
|
|
||||||
return _this2;
|
return _this2;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||||
|
|
||||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
|||||||
@ -11,12 +11,12 @@ function (_Foo) {
|
|||||||
babelHelpers.classCallCheck(this, Test);
|
babelHelpers.classCallCheck(this, Test);
|
||||||
woops.super.test();
|
woops.super.test();
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this).call(_this);
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).apply(this, arguments));
|
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).apply(this, arguments));
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (_ref = Test.__proto__ || Object.getPrototypeOf(Test)).call.apply(_ref, [this, "test"].concat(Array.prototype.slice.call(arguments))));
|
_this = babelHelpers.possibleConstructorReturn(this, (_ref = Test.__proto__ || Object.getPrototypeOf(Test)).call.apply(_ref, [this, "test"].concat(Array.prototype.slice.call(arguments))));
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this).apply(_this, arguments);
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).apply(_this, arguments);
|
||||||
|
|
||||||
(_babelHelpers$get = babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this)).call.apply(_babelHelpers$get, [_this, "test"].concat(Array.prototype.slice.call(arguments)));
|
(_babelHelpers$get = babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this))).call.apply(_babelHelpers$get, [_this, "test"].concat(Array.prototype.slice.call(arguments)));
|
||||||
|
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,8 @@ function (_Foo) {
|
|||||||
|
|
||||||
babelHelpers.classCallCheck(this, Test);
|
babelHelpers.classCallCheck(this, Test);
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this);
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this));
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this).whatever;
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ function (_Foo) {
|
|||||||
|
|
||||||
babelHelpers.classCallCheck(this, Test);
|
babelHelpers.classCallCheck(this, Test);
|
||||||
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
_this = babelHelpers.possibleConstructorReturn(this, (Test.__proto__ || Object.getPrototypeOf(Test)).call(this));
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this).whatever();
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).whatever();
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", _this).call(_this);
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
if (eval("false")) super();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
if (eval("false")) super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
if (eval("false")) _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
return babelHelpers.possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => super();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => super();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Foo();
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var fn = () => _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
|
||||||
|
fn();
|
||||||
|
return babelHelpers.possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => super();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var fn = () => _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
|
||||||
|
return babelHelpers.possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
return babelHelpers.possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "missing super() call in constructor",
|
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
var Test = function Test() {
|
var Test = function Test() {
|
||||||
babelHelpers.classCallCheck(this, Test);
|
babelHelpers.classCallCheck(this, Test);
|
||||||
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
babelHelpers.get(Test.prototype.__proto__ || Object.getPrototypeOf(Test.prototype), "hasOwnProperty", babelHelpers.assertThisInitialized(this)).call(this, "test");
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
super.foo(super());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
function _get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return _get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }
|
||||||
|
|
||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
_inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
_classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
_get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this, _this = _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this)));
|
||||||
|
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"throws": "'super.*' is not allowed before super()",
|
"plugins": ["transform-classes", "transform-block-scoping"]
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
super.foo();
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
function _get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return _get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }
|
||||||
|
|
||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
_inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
_classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
_get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", _assertThisInitialized(_this)).call(_this);
|
||||||
|
|
||||||
|
return _this = _possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"throws": "'super.*' is not allowed before super()",
|
"plugins": ["transform-classes", "transform-block-scoping"]
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
class Foo extends Bar {
|
class Foo extends Bar {
|
||||||
constructor() {
|
constructor() {
|
||||||
const t = () => super.test()
|
var t = () => super.test()
|
||||||
super.foo();
|
super.foo();
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
class Bar {
|
||||||
|
test() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const t = () => super.test()
|
||||||
|
t();
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
|
|
||||||
|
babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "foo", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
|
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
"throws": "'super.*' is not allowed before super()",
|
"plugins": ["external-helpers", "transform-classes", "transform-block-scoping"]
|
||||||
"plugins": ["external-helpers", "transform-classes"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const t = () => super.test()
|
||||||
|
super();
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
class Bar {
|
||||||
|
test() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const t = () => super.test()
|
||||||
|
super();
|
||||||
|
t();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Foo();
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
|
|
||||||
|
_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
t();
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["external-helpers", "transform-classes", "transform-block-scoping"]
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
class Bar {
|
||||||
|
test() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const t = () => super.test()
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Foo();
|
||||||
@ -8,7 +8,7 @@ function (_Bar) {
|
|||||||
|
|
||||||
babelHelpers.classCallCheck(this, Foo);
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", _this).call(_this);
|
var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
|
|
||||||
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ function (_Bar) {
|
|||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
babelHelpers.classCallCheck(this, Foo);
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), (_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this))).method, _this).call(_this);
|
babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), (_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this))).method, babelHelpers.assertThisInitialized(_this)).call(_this);
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
super(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this, babelHelpers.assertThisInitialized(_this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "'this' is not allowed before super()",
|
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => this;
|
||||||
|
fn();
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => this;
|
||||||
|
fn();
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var fn = () => babelHelpers.assertThisInitialized(_this);
|
||||||
|
|
||||||
|
fn();
|
||||||
|
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => this;
|
||||||
|
super();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
const fn = () => this;
|
||||||
|
super();
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Foo();
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
|
||||||
|
var fn = () => babelHelpers.assertThisInitialized(_this);
|
||||||
|
|
||||||
|
_this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
fn();
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
Foo[this];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
Foo[this];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
Foo[babelHelpers.assertThisInitialized(_this)];
|
||||||
|
return babelHelpers.possibleConstructorReturn(_this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
class Bar {}
|
||||||
|
|
||||||
|
class Foo extends Bar {
|
||||||
|
constructor() {
|
||||||
|
this.foo = "bar";
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.throws(() => new Foo());
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var Foo =
|
||||||
|
/*#__PURE__*/
|
||||||
|
function (_Bar) {
|
||||||
|
babelHelpers.inherits(Foo, _Bar);
|
||||||
|
|
||||||
|
function Foo() {
|
||||||
|
var _this;
|
||||||
|
|
||||||
|
babelHelpers.classCallCheck(this, Foo);
|
||||||
|
_this.foo = "bar";
|
||||||
|
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Foo;
|
||||||
|
}(Bar);
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "'this' is not allowed before super()",
|
|
||||||
"plugins": ["transform-classes"]
|
|
||||||
}
|
|
||||||
@ -19,10 +19,12 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|||||||
|
|
||||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||||
|
|
||||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||||
|
|
||||||
var App =
|
var App =
|
||||||
/*#__PURE__*/
|
/*#__PURE__*/
|
||||||
function (_Component) {
|
function (_Component) {
|
||||||
@ -39,7 +41,7 @@ function (_Component) {
|
|||||||
args[_key] = arguments[_key];
|
args[_key] = arguments[_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = App.__proto__ || Object.getPrototypeOf(App)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_this, "exportType", {
|
return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = App.__proto__ || Object.getPrototypeOf(App)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "exportType", {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user