fix(es/transforms/compat): Use _createSuper for super classes (#2699)

swc_ecma_transforms_base:
 - Add `_createSuper` helper.
 - Add `_isNativeReflectConstruct` helper.

swc_ecma_transforms_compat:
 - `classes`: Apply `_createSuper` to the super classes.
This commit is contained in:
Donny/강동윤 2021-11-10 16:15:03 +09:00 committed by GitHub
parent 2be8559e35
commit 8edd72ed73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 1116 additions and 424 deletions

View File

@ -82,12 +82,38 @@ function _superPropBase(object, property) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var ColouredCanvasElement = /*#__PURE__*/ function(CanvasElement) {
"use strict";
_inherits(ColouredCanvasElement, CanvasElement);
var _super = _createSuper(ColouredCanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(ColouredCanvasElement, [
{

View File

@ -140,6 +140,31 @@ function _wrapNativeSuper(Class) {
};
return _wrapNativeSuper(Class);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var Element = /*#__PURE__*/ function() {
function Element() {
_classCallCheck(this, Element);
@ -156,9 +181,10 @@ var Element = /*#__PURE__*/ function() {
}();
var CanvasElement = /*#__PURE__*/ function(Element) {
_inherits(CanvasElement, Element);
var _super = _createSuper(CanvasElement);
function CanvasElement() {
_classCallCheck(this, CanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(CanvasElement).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(CanvasElement, [
{
@ -173,9 +199,10 @@ var CanvasElement = /*#__PURE__*/ function(Element) {
}(_wrapNativeSuper(Element));
var ColouredCanvasElement = /*#__PURE__*/ function(CanvasElement) {
_inherits(ColouredCanvasElement, CanvasElement);
var _super = _createSuper(ColouredCanvasElement);
function ColouredCanvasElement() {
_classCallCheck(this, ColouredCanvasElement);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(ColouredCanvasElement, [
{
@ -190,9 +217,10 @@ var ColouredCanvasElement = /*#__PURE__*/ function(CanvasElement) {
}(CanvasElement);
var ColouredSquare = /*#__PURE__*/ function(ColouredCanvasElement) {
_inherits(ColouredSquare, ColouredCanvasElement);
var _super = _createSuper(ColouredSquare);
function ColouredSquare() {
_classCallCheck(this, ColouredSquare);
return _possibleConstructorReturn(this, _getPrototypeOf(ColouredSquare).apply(this, arguments));
return _super.apply(this, arguments);
}
return ColouredSquare;
}(ColouredCanvasElement);

View File

@ -44,6 +44,31 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var MyClass = function MyClass() {
"use strict";
_classCallCheck(this, MyClass);
@ -52,9 +77,10 @@ export var fn = function() {
var _class = /*#__PURE__*/ function(MyClass) {
"use strict";
_inherits(_class, MyClass);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(MyClass);

View File

@ -44,6 +44,31 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var MyClass = function MyClass() {
"use strict";
_classCallCheck(this, MyClass);
@ -52,9 +77,10 @@ export var fn = function() {
var _class = /*#__PURE__*/ function(MyClass) {
"use strict";
_inherits(_class, MyClass);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(MyClass);

View File

@ -44,6 +44,31 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var Component = function Component() {
"use strict";
_classCallCheck(this, Component);
@ -56,9 +81,10 @@ var withTeamsForUser = function(_WrappedComponent) {
var _class = /*#__PURE__*/ function(Component) {
"use strict";
_inherits(_class, Component);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(Component);

View File

@ -44,12 +44,38 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
export var a = /*#__PURE__*/ function(Component) {
"use strict";
_inherits(_class, Component);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(Component);

View File

@ -44,13 +44,39 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var withTeamsForUser = function() {
var _class = /*#__PURE__*/ function(Component) {
"use strict";
_inherits(_class, Component);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(Component);

View File

@ -44,6 +44,31 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var MyClass = function MyClass() {
"use strict";
_classCallCheck(this, MyClass);
@ -52,9 +77,10 @@ export var fn = function() {
var _class = /*#__PURE__*/ function(MyClass) {
"use strict";
_inherits(_class, MyClass);
var _super = _createSuper(_class);
function _class() {
_classCallCheck(this, _class);
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
return _super.apply(this, arguments);
}
return _class;
}(MyClass);

View File

@ -429,6 +429,31 @@ function _toPropertyKey(arg) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var SomeClass1 = _decorate([], function(_initialize) {
var SomeClass = function SomeClass() {
"use strict";
@ -454,10 +479,11 @@ var OtherClass1 = _decorate([], function(_initialize, _SomeClass1) {
var OtherClass = /*#__PURE__*/ function(_SomeClass) {
"use strict";
_inherits(OtherClass, _SomeClass);
var _super = _createSuper(OtherClass);
function OtherClass() {
_classCallCheck(this, OtherClass);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(OtherClass).apply(this, arguments));
_this = _super.apply(this, arguments);
_initialize(_assertThisInitialized(_this));
return _this;
}

View File

@ -102,13 +102,39 @@ function _wrapNativeSuper(Class) {
};
return _wrapNativeSuper(Class);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var CustomError = /*#__PURE__*/ function(Error) {
"use strict";
_inherits(CustomError, Error);
var _super = _createSuper(CustomError);
function CustomError(message) {
_classCallCheck(this, CustomError);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(CustomError).call(this, message)); // 'Error' breaks prototype chain here
_this = _super.call(this, message); // 'Error' breaks prototype chain here
Object.setPrototypeOf(_assertThisInitialized(_this), _this.constructor.prototype); // restore prototype chain
return _this;
}

View File

@ -2,20 +2,20 @@
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var g, b = require("react/jsx-runtime"), c = function(g) {
if (g && g.__esModule) return g;
var a, b = require("react/jsx-runtime"), c = function(a) {
if (a && a.__esModule) return a;
var b = {
};
if (null != g) {
for(var b in g)if (Object.prototype.hasOwnProperty.call(g, b)) {
var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(g, b) : {
if (null != a) {
for(var b in a)if (Object.prototype.hasOwnProperty.call(a, b)) {
var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, b) : {
};
d.get || d.set ? Object.defineProperty(b, b, d) : b[b] = g[b];
d.get || d.set ? Object.defineProperty(b, b, d) : b[b] = a[b];
}
}
return b.default = g, b;
}(require("react")), d = (g = require("prop-types")) && g.__esModule ? g : {
default: g
return b.default = a, b;
}(require("react")), d = (a = require("prop-types")) && a.__esModule ? a : {
default: a
};
function e(a, b) {
for(var c = 0; c < b.length; c++){
@ -23,13 +23,13 @@ function e(a, b) {
d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(a, d.key, d);
}
}
function f(g, b, c) {
return b in g ? Object.defineProperty(g, b, {
function f(a, b, c) {
return b in a ? Object.defineProperty(a, b, {
value: c,
enumerable: !0,
configurable: !0,
writable: !0
}) : g[b] = c, g;
}) : a[b] = c, a;
}
function b(d) {
return b = Object.setPrototypeOf ? Object.getPrototypeOf : function b(d) {
@ -53,21 +53,9 @@ function c(d, e) {
return d.__proto__ = e, d;
}, c(d, e);
}
var j = function(d) {
var l = function(d) {
"use strict";
var b, g, i;
function j() {
var c, a, e, g;
return !function(a, b) {
if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function");
}(this, j), a = this, e = b(j).apply(this, arguments), (c = e && ("object" == ((g = e) && "undefined" != typeof Symbol && g.constructor === Symbol ? "symbol" : typeof g) || "function" == typeof e) ? e : (function(a) {
if (void 0 === a) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(a)).storeHighlightedItemReference = function(a) {
c.props.onHighlightedItemChange(null === a ? null : a.item);
}, c;
}
return !function(a, b) {
!function(a, b) {
if ("function" != typeof b && null !== b) throw new TypeError("Super expression must either be null or a function");
a.prototype = Object.create(b && b.prototype, {
constructor: {
@ -76,7 +64,40 @@ var j = function(d) {
configurable: !0
}
}), b && c(a, b);
}(j, d), b = j, g = [
}(l, d);
var b, g, i, k = function(c) {
var d = function() {
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1;
if ("function" == typeof Proxy) return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch (a) {
return !1;
}
}();
return function() {
var a, a, f, g, h = b(c);
if (d) {
var i = b(this).constructor;
g = Reflect.construct(h, arguments, i);
} else g = h.apply(this, arguments);
return a = this, (f = g) && ("object" == ((a = f) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof f) ? f : (function(a) {
if (void 0 === a) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(a);
};
}(l);
function l() {
var a;
return !function(a, b) {
if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function");
}(this, l), a = k.apply(this, arguments), a.storeHighlightedItemReference = function(b) {
a.props.onHighlightedItemChange(null === b ? null : b.item);
}, a;
}
return b = l, g = [
{
key: "shouldComponentUpdate",
value: function(a) {
@ -111,9 +132,9 @@ var j = function(d) {
}));
}
}
], e(b.prototype, g), i && e(b, i), j;
], e(b.prototype, g), i && e(b, i), l;
}(c.Component);
j.propTypes = {
l.propTypes = {
items: d.default.array.isRequired,
itemProps: d.default.oneOfType([
d.default.object,
@ -127,6 +148,6 @@ j.propTypes = {
getItemId: d.default.func.isRequired,
theme: d.default.func.isRequired,
keyPrefix: d.default.string.isRequired
}, j.defaultProps = {
}, l.defaultProps = {
sectionIndex: null
}, exports.default = j, new j();
}, exports.default = l, new l();

View File

@ -2,18 +2,18 @@
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.default = void 0;
var a = require("react/jsx-runtime"), b = function(g) {
if (g && g.__esModule) return g;
var a = require("react/jsx-runtime"), b = function(a) {
if (a && a.__esModule) return a;
var b = {
};
if (null != g) {
for(var b in g)if (Object.prototype.hasOwnProperty.call(g, b)) {
var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(g, b) : {
if (null != a) {
for(var b in a)if (Object.prototype.hasOwnProperty.call(a, b)) {
var d = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(a, b) : {
};
d.get || d.set ? Object.defineProperty(b, b, d) : b[b] = g[b];
d.get || d.set ? Object.defineProperty(b, b, d) : b[b] = a[b];
}
}
return b.default = g, b;
return b.default = a, b;
}(require("react"));
function c(a, b) {
for(var c = 0; c < b.length; c++){
@ -21,13 +21,13 @@ function c(a, b) {
d.enumerable = d.enumerable || !1, d.configurable = !0, "value" in d && (d.writable = !0), Object.defineProperty(a, d.key, d);
}
}
function d(g, b, c) {
return b in g ? Object.defineProperty(g, b, {
function d(a, b, c) {
return b in a ? Object.defineProperty(a, b, {
value: c,
enumerable: !0,
configurable: !0,
writable: !0
}) : g[b] = c, g;
}) : a[b] = c, a;
}
function b(d) {
return b = Object.setPrototypeOf ? Object.getPrototypeOf : function b(d) {
@ -51,21 +51,9 @@ function c(d, e) {
return d.__proto__ = e, d;
}, c(d, e);
}
var j = function(d) {
var k = function(d) {
"use strict";
var b, g, i;
function j() {
var c, a, f, g;
return !function(a, b) {
if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function");
}(this, j), a = this, f = b(j).apply(this, arguments), (c = f && ("object" == ((g = f) && "undefined" != typeof Symbol && g.constructor === Symbol ? "symbol" : typeof g) || "function" == typeof f) ? f : (function(a) {
if (void 0 === a) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(a)).storeHighlightedItemReference = function(a) {
c.props.onHighlightedItemChange(null === a ? null : a.item);
}, c;
}
return !function(a, b) {
!function(a, b) {
if ("function" != typeof b && null !== b) throw new TypeError("Super expression must either be null or a function");
a.prototype = Object.create(b && b.prototype, {
constructor: {
@ -74,7 +62,40 @@ var j = function(d) {
configurable: !0
}
}), b && c(a, b);
}(j, d), b = j, g = [
}(k, d);
var b, g, i, j = function(c) {
var d = function() {
if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
if (Reflect.construct.sham) return !1;
if ("function" == typeof Proxy) return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch (a) {
return !1;
}
}();
return function() {
var a, a, f, g, h = b(c);
if (d) {
var i = b(this).constructor;
g = Reflect.construct(h, arguments, i);
} else g = h.apply(this, arguments);
return a = this, (f = g) && ("object" == ((a = f) && "undefined" != typeof Symbol && a.constructor === Symbol ? "symbol" : typeof a) || "function" == typeof f) ? f : (function(a) {
if (void 0 === a) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return a;
})(a);
};
}(k);
function k() {
var a;
return !function(a, b) {
if (!(a instanceof b)) throw new TypeError("Cannot call a class as a function");
}(this, k), a = j.apply(this, arguments), a.storeHighlightedItemReference = function(b) {
a.props.onHighlightedItemChange(null === b ? null : b.item);
}, a;
}
return b = k, g = [
{
key: "shouldComponentUpdate",
value: function(a) {
@ -111,10 +132,10 @@ var j = function(d) {
}));
}
}
], c(b.prototype, g), i && c(b, i), j;
], c(b.prototype, g), i && c(b, i), k;
}(b.Component);
j.propTypes = {
k.propTypes = {
items: 500
}, j.defaultProps = {
}, k.defaultProps = {
sectionIndex: null
}, exports.default = j, new j();
}, exports.default = k, new k();

View File

@ -92,13 +92,39 @@ function _setPrototypeOf(o, p) {
var _typeof = function(obj) {
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
};
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var ItemsList = /*#__PURE__*/ function(Component) {
"use strict";
_inherits(ItemsList, Component);
var _super = _createSuper(ItemsList);
function ItemsList() {
_classCallCheck(this, ItemsList);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(ItemsList).apply(this, arguments));
_this = _super.apply(this, arguments);
_this.storeHighlightedItemReference = function(highlightedItem) {
_this.props.onHighlightedItemChange(highlightedItem === null ? null : highlightedItem.item);
};

View File

@ -0,0 +1,14 @@
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}

View File

@ -0,0 +1,11 @@
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () { }));
return true;
} catch (e) {
return false;
}
}

View File

@ -244,6 +244,14 @@ define_helpers!(Helpers {
class_static_private_method_get: (class_check_private_static_access),
class_check_private_static_access: (),
is_native_reflect_construct: (),
create_super: (
get_prototype_of,
is_native_reflect_construct,
possible_constructor_return
),
});
pub fn inject_helpers() -> impl Fold + VisitMut {

View File

@ -4,7 +4,7 @@ use swc_common::{Mark, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_transforms_base::helper;
use swc_ecma_transforms_classes::{fold_only_key, get_prototype_of};
use swc_ecma_utils::{quote_ident, ExprFactory};
use swc_ecma_utils::{private_ident, quote_ident, ExprFactory};
use swc_ecma_visit::{noop_fold_type, noop_visit_type, Fold, FoldWith, Node, Visit, VisitWith};
pub(super) struct SuperCallFinder {
@ -163,14 +163,152 @@ pub(super) fn constructor_fn(c: Constructor) -> Function {
pub(super) struct ConstructorFolder<'a> {
pub class_name: &'a Ident,
pub mode: Option<SuperFoldingMode>,
/// Variables named `thisSuper` will be added if `super.foo` or
/// `super.foo()` is used in constructor.
pub vars: &'a mut Vec<VarDeclarator>,
pub cur_this_super: Option<Ident>,
/// Mark for `_this`
pub mark: Mark,
pub is_constructor_default: bool,
pub super_var: Option<Ident>,
/// True when recursing into other function or class.
pub ignore_return: bool,
pub in_injected_define_property_call: bool,
}
impl ConstructorFolder<'_> {
/// `Ok()` means it's processed and children are folded.
fn handle_super_assignment(&mut self, e: Expr) -> Result<Expr, Expr> {
match e {
Expr::Assign(AssignExpr {
span,
left,
op: op!("="),
right,
}) => {
let left = left.normalize_expr();
match left {
PatOrExpr::Expr(left_expr) => match &*left_expr {
Expr::Member(MemberExpr {
obj: ExprOrSuper::Super(..),
..
}) => {
let right = right.fold_children_with(self);
return Ok(self.handle_super_access(*left_expr, Some(right)));
}
_ => Err(Expr::Assign(AssignExpr {
span,
left: PatOrExpr::Expr(left_expr),
op: op!("="),
right,
})),
},
_ => Err(Expr::Assign(AssignExpr {
span,
left,
op: op!("="),
right,
})),
}
}
_ => Err(e),
}
}
fn handle_super_access(&mut self, e: Expr, set_to: Option<Box<Expr>>) -> Expr {
match e {
Expr::Member(MemberExpr {
span,
obj: ExprOrSuper::Super(..),
prop,
computed,
}) => {
let this_var = quote_ident!(DUMMY_SP.apply_mark(self.mark), "_this");
let this_super = private_ident!("_thisSuper");
self.cur_this_super = Some(this_super.clone());
self.vars.push(VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(this_super.clone().into()),
init: None,
definite: Default::default(),
});
// _thisSuper = _assertThisInitialized(_this)
let init_this_super = Box::new(Expr::Assign(AssignExpr {
span: DUMMY_SP,
op: op!("="),
left: PatOrExpr::Pat(Box::new(this_super.clone().into())),
right: Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: helper!(assert_this_initialized, "assertThisInitialized"),
args: vec![this_var.as_arg()],
type_args: Default::default(),
})),
}));
// _getPrototypeOf(Foo.prototype)
let get_proto = Box::new(Expr::Call(CallExpr {
span,
callee: helper!(get_prototype_of, "getPrototypeOf"),
args: vec![self
.class_name
.clone()
.make_member(quote_ident!("prototype"))
.as_arg()],
type_args: Default::default(),
}));
Expr::Call(CallExpr {
span: DUMMY_SP,
callee: if set_to.is_some() {
helper!(set, "set")
} else {
helper!(get, "get")
},
args: {
let mut args = vec![
Expr::Seq(SeqExpr {
span: DUMMY_SP,
exprs: vec![init_this_super, get_proto],
})
.as_arg(),
if computed {
prop.as_arg()
} else {
let prop = prop.expect_ident();
Str {
span: prop.span,
value: prop.sym,
has_escape: false,
kind: Default::default(),
}
.as_arg()
},
];
let is_set = set_to.is_some();
args.extend(set_to.map(|v| v.as_arg()));
args.push(this_super.clone().as_arg());
if is_set {
args.push(true.as_arg());
}
args
},
type_args: Default::default(),
})
}
_ => e,
}
}
}
/// `None`: `return _possibleConstructorReturn`
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum SuperFoldingMode {
@ -190,10 +328,51 @@ impl Fold for ConstructorFolder<'_> {
ignore_return!(fold_arrow_expr, ArrowExpr);
ignore_return!(fold_constructor, Constructor);
fn fold_call_expr(&mut self, e: CallExpr) -> CallExpr {
match &e.callee {
ExprOrSuper::Expr(callee) => match &**callee {
Expr::Member(MemberExpr {
obj: ExprOrSuper::Super(..),
..
}) => {
let old = self.cur_this_super.take();
let mut e = e.fold_children_with(self);
let this_super = self.cur_this_super.take().unwrap();
self.cur_this_super = old;
e.args.insert(0, this_super.as_arg());
CallExpr {
span: e.span,
callee: e
.callee
.expect_expr()
.make_member(quote_ident!("call"))
.as_callee(),
args: e.args,
type_args: Default::default(),
}
}
_ => return e.fold_children_with(self),
},
_ => return e.fold_children_with(self),
}
}
fn fold_expr(&mut self, expr: Expr) -> Expr {
match self.mode {
Some(SuperFoldingMode::Assign) => {}
_ => return expr,
_ => {
let expr = match self.handle_super_assignment(expr) {
Ok(v) => v,
Err(v) => v.fold_children_with(self),
};
return self.handle_super_access(expr, None);
}
}
// We pretend method folding mode for while folding injected `_defineProperty`
@ -218,7 +397,10 @@ impl Fold for ConstructorFolder<'_> {
_ => {}
}
let expr = expr.fold_children_with(self);
let expr = match self.handle_super_assignment(expr) {
Ok(v) => v,
Err(v) => v.fold_children_with(self),
};
match expr {
Expr::This(e) => Expr::Ident(Ident::new("_this".into(), e.span.apply_mark(self.mark))),
@ -227,11 +409,34 @@ impl Fold for ConstructorFolder<'_> {
args,
..
}) => {
let right = Box::new(make_possible_return_value(ReturningMode::Prototype {
class_name: self.class_name.clone(),
args: Some(args),
is_constructor_default: self.is_constructor_default,
}));
let right = match self.super_var.clone() {
Some(super_var) => Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: if self.is_constructor_default {
super_var.make_member(quote_ident!("apply")).as_callee()
} else {
super_var.make_member(quote_ident!("call")).as_callee()
},
args: if self.is_constructor_default {
vec![
ThisExpr { span: DUMMY_SP }.as_arg(),
quote_ident!("arguments").as_arg(),
]
} else {
let mut call_args = vec![ThisExpr { span: DUMMY_SP }.as_arg()];
call_args.extend(args);
call_args
},
type_args: Default::default(),
})),
None => Box::new(make_possible_return_value(ReturningMode::Prototype {
class_name: self.class_name.clone(),
args: Some(args),
is_constructor_default: self.is_constructor_default,
})),
};
Expr::Assign(AssignExpr {
span: DUMMY_SP,
@ -242,7 +447,8 @@ impl Fold for ConstructorFolder<'_> {
right,
})
}
_ => expr,
_ => self.handle_super_access(expr, None),
}
}
@ -273,11 +479,33 @@ impl Fold for ConstructorFolder<'_> {
args,
..
}) => {
let expr = make_possible_return_value(ReturningMode::Prototype {
is_constructor_default: self.is_constructor_default,
class_name: self.class_name.clone(),
args: Some(args),
});
let expr = match self.super_var.clone() {
Some(super_var) => Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: if self.is_constructor_default {
super_var.make_member(quote_ident!("apply")).as_callee()
} else {
super_var.make_member(quote_ident!("call")).as_callee()
},
args: if self.is_constructor_default {
vec![
ThisExpr { span: DUMMY_SP }.as_arg(),
quote_ident!("arguments").as_arg(),
]
} else {
let mut call_args = vec![ThisExpr { span: DUMMY_SP }.as_arg()];
call_args.extend(args);
call_args
},
type_args: Default::default(),
})),
None => Box::new(make_possible_return_value(ReturningMode::Prototype {
is_constructor_default: self.is_constructor_default,
class_name: self.class_name.clone(),
args: Some(args),
})),
};
match self.mode {
Some(SuperFoldingMode::Assign) => AssignExpr {
@ -286,7 +514,7 @@ impl Fold for ConstructorFolder<'_> {
quote_ident!(DUMMY_SP.apply_mark(self.mark), "_this").into(),
))),
op: op!("="),
right: expr.into(),
right: expr,
}
.into_stmt(),
Some(SuperFoldingMode::Var) => Stmt::Decl(Decl::Var(VarDecl {
@ -298,7 +526,7 @@ impl Fold for ConstructorFolder<'_> {
name: Pat::Ident(
quote_ident!(DUMMY_SP.apply_mark(self.mark), "_this").into(),
),
init: Some(expr.into()),
init: Some(expr),
definite: false,
}],
})),

View File

@ -427,6 +427,29 @@ where
);
}
let super_var = super_class_ident.as_ref().map(|_| {
let var = private_ident!("_super");
stmts.push(Stmt::Decl(Decl::Var(VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Var,
declare: Default::default(),
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(var.clone().into()),
init: Some(Box::new(Expr::Call(CallExpr {
span: DUMMY_SP,
callee: helper!(create_super, "createSuper"),
args: vec![class_name.clone().as_arg()],
type_args: Default::default(),
}))),
definite: Default::default(),
}],
})));
var
});
// Marker for `_this`
let this_mark = Mark::fresh(Mark::root());
@ -457,6 +480,7 @@ where
insert_this |= inserted_this;
}
let mut vars = vec![];
let mut body = constructor.body.unwrap().stmts;
// should we insert `var _this`?
@ -486,15 +510,18 @@ where
// We should fold body instead of constructor itself.
// Handle `super()`
body = body.fold_with(&mut ConstructorFolder {
is_constructor_default,
class_name: &class_name,
// This if expression is required to handle super() call in all case
mode: if insert_this {
Some(SuperFoldingMode::Assign)
} else {
mode
},
vars: &mut vars,
// This if expression is required to handle super() call in all case
cur_this_super: None,
mark: this_mark,
is_constructor_default,
super_var,
ignore_return: false,
in_injected_define_property_call: false,
});
@ -503,18 +530,21 @@ where
|| mode == Some(SuperFoldingMode::Assign);
if insert_this {
vars.push(VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(this.clone().into()),
init: None,
definite: false,
});
}
if !vars.is_empty() {
prepend(
&mut body,
Stmt::Decl(Decl::Var(VarDecl {
span: DUMMY_SP,
declare: false,
kind: VarDeclKind::Var,
decls: vec![VarDeclarator {
span: DUMMY_SP,
name: Pat::Ident(this.clone().into()),
init: None,
definite: false,
}],
decls: vars,
})),
);
}

View File

@ -135,15 +135,20 @@ export var Foo = function() {
class HomePage extends React.Component {}
"#,
r#"
var HomePage = function(_Component) {
'use strict';
_inherits(HomePage, _Component);
function HomePage() {
_classCallCheck(this, HomePage);
return _possibleConstructorReturn(this, _getPrototypeOf(HomePage).apply(this, arguments));
}
return HomePage;
}(React.Component);
var HomePage = /*#__PURE__*/function (_Component) {
"use strict";
_inherits(HomePage, _Component);
var _super = _createSuper(HomePage);
function HomePage() {
_classCallCheck(this, HomePage);
return _super.apply(this, arguments);
}
return HomePage;
}(React.Component);
"#
);
@ -285,10 +290,11 @@ class B extends A {
var B = function(A) {
'use strict';
_inherits(B, A);
var _super = _createSuper(B);
function B(num) {
_classCallCheck(this, B);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(B).call(this));
_this = _super.call(this);
_this.b_num = num;
return _this;
}

File diff suppressed because it is too large Load Diff

View File

@ -1228,10 +1228,10 @@ test!(
let Foo = function(Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
return _possibleConstructorReturn(this,
_getPrototypeOf(Foo).apply(this, arguments));
return _super.apply(this, arguments);
}
return Foo;
}(Bar);

View File

@ -144,12 +144,12 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "bar", "foo");
return _this;
}
@ -183,12 +183,12 @@ function (Parent) {
'use strict';
_inherits(Child, Parent);
var _super = _createSuper(Child);
function Child() {
_classCallCheck(this, Child);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Child).call(this));
_this = _super.call(this);
_scopedFunctionWithThis.set(_assertThisInitialized(_this), {
writable: true,
@ -257,17 +257,17 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
if (condition) {
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "bar", "foo");
} else {
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_defineProperty(_assertThisInitialized(_this), "bar", "foo");
}
@ -391,9 +391,10 @@ function withContext(ComposedComponent) {
var WithContext = function(Component) {
'use strict';
_inherits(WithContext, Component);
var _super = _createSuper(WithContext);
function WithContext() {
_classCallCheck(this, WithContext);
return _possibleConstructorReturn(this, _getPrototypeOf(WithContext).apply(this, arguments));
return _super.apply(this, arguments);
}
return WithContext;
}(Component);
@ -584,12 +585,12 @@ var Hello = function Hello() {
var Outer = function (Hello) {
'use strict';
_inherits(Outer, Hello);
var _super = _createSuper(Outer);
function Outer() {
_classCallCheck(this, Outer);
var _this;
var _ref = _this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this));
var _ref = _this = _super.call(this);
var Inner = function Inner() {
_classCallCheck(this, Inner);
@ -653,21 +654,21 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
if (condition) {
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_bar.set(_assertThisInitialized(_this), {
writable: true,
value: "foo"
});
} else {
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_bar.set(_assertThisInitialized(_this), {
writable: true,
@ -870,7 +871,7 @@ class B extends A {
}
"#,
r#"
"
var A =
/*#__PURE__*/
function () {
@ -881,9 +882,9 @@ function () {
}
_createClass(A, [{
key: "foo",
key: 'foo',
value: function foo() {
return "bar";
return 'bar';
}
}]);
return A;
@ -895,20 +896,22 @@ function (A) {
'use strict';
_inherits(B, A);
var _super = _createSuper(B);
function B() {
_classCallCheck(this, B);
var _this;
var _thisSuper, _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(B).apply(this, arguments));
_defineProperty(_assertThisInitialized(_this), "foo", _get(_getPrototypeOf(B.prototype), "foo", _assertThisInitialized(_this)).call(_this));
_this = _super.apply(this, arguments);
_defineProperty(_assertThisInitialized(_this), 'foo', _get((_thisSuper = \
_assertThisInitialized(_this), _getPrototypeOf(B.prototype)), 'foo', \
_thisSuper).call(_thisSuper));
return _this;
}
return B;
}(A);
"#
"
);
test!(
@ -1390,12 +1393,12 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
_this = _super.call(this);
_bar.set(_assertThisInitialized(_this), {
writable: true,
@ -1441,10 +1444,10 @@ var Outer = function Outer() {
var Test = function (_super) {
_inherits(Test, _super);
var _super1 = _createSuper(Test);
function Test() {
_classCallCheck(this, Test);
return _possibleConstructorReturn(this, _getPrototypeOf(Test).apply(this, arguments));
return _super1.apply(this, arguments);
}
return Test;
@ -1526,13 +1529,13 @@ var Foo = function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
var _temp;
foo((_temp = _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this)), _defineProperty(_assertThisInitialized(_this), "bar", "foo"), _temp));
foo((_temp = _this = _super.call(this), _defineProperty(_assertThisInitialized(_this), "bar", "foo"), _temp));
return _possibleConstructorReturn(_this);
}
@ -1720,12 +1723,12 @@ function (Foo) {
'use strict';
_inherits(Bar, Foo);
var _super = _createSuper(Bar);
function Bar() {
_classCallCheck(this, Bar);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Bar).apply(this, arguments));
_this = _super.apply(this, arguments);
_prop1.set(_assertThisInitialized(_this), {
writable: true,
@ -1782,16 +1785,16 @@ function (A) {
'use strict';
_inherits(B, A);
var _super = _createSuper(B);
function B() {
_classCallCheck(this, B);
var _this;
var _thisSuper, _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(B).apply(this, arguments));
_this = _super.apply(this, arguments);
_foo.set(_assertThisInitialized(_this), {
writable: true,
value: _get(_getPrototypeOf(B.prototype), "foo", _assertThisInitialized(_this)).call(_this)
value: _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(B.prototype)), "foo", _thisSuper).call(_thisSuper)
});
return _this;
@ -1900,12 +1903,13 @@ var Hello = function () {
var Outer = function (Hello) {
'use strict';
_inherits(Outer, Hello);
var _super = _createSuper(Outer);
function Outer() {
_classCallCheck(this, Outer);
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this));
var _thisSuper;
var _this = _super.call(this);
var _ref = _get(_getPrototypeOf(Outer.prototype), 'toString', _assertThisInitialized(_this)).call(_this);
var _ref = _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper);
var Inner = function Inner() {
_classCallCheck(this, Inner);
@ -2167,12 +2171,12 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments))
_this = _super.apply(this, arguments);
_defineProperty(_assertThisInitialized(_this), "bar", "foo");
return _this;
}
@ -2658,14 +2662,13 @@ function (Bar) {
'use strict';
_inherits(Foo, Bar);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
var _this;
var _temp;
foo((_temp = _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this)),
_bar.set(_assertThisInitialized(_this), {
foo((_temp = _this = _super.call(this), _bar.set(_assertThisInitialized(_this), {
writable: true,
value: "foo"
}), _temp));
@ -4704,10 +4707,10 @@ function (A) {
"use strict";
_inherits(B, A);
var _super = _createSuper(B);
function B() {
_classCallCheck(this, B);
return _possibleConstructorReturn(this, _getPrototypeOf(B).apply(this, arguments));
return _super.apply(this, arguments);
}
return B;

View File

@ -0,0 +1,9 @@
const UnknownNativeClass = Array;
class Foo extends UnknownNativeClass {
}
new Foo()
console.log('PASS')

View File

@ -0,0 +1,2 @@
class Foo extends UnknownNativeClass {
}

View File

@ -0,0 +1,10 @@
let Foo = function(UnknownNativeClass) {
"use strict";
_inherits(Foo, UnknownNativeClass);
var _super = _createSuper(Foo);
function Foo() {
_classCallCheck(this, Foo);
return _super.apply(this, arguments);
}
return Foo;
}(UnknownNativeClass);

View File

@ -304,10 +304,10 @@ let Login =
function (_Component) {
'use strict';
_inherits(Login, _Component);
var _super = _createSuper(Login);
function Login() {
_classCallCheck(this, Login);
return _possibleConstructorReturn(this, _getPrototypeOf(Login).apply(this, arguments));
return _super.apply(this, arguments);
}
_createClass(Login, [{