fix: remove check for super in arrow function
This commit is contained in:
parent
c5bad22767
commit
819056e94a
@ -23,15 +23,20 @@ const noMethodVisitor = {
|
||||
};
|
||||
|
||||
const verifyConstructorVisitor = visitors.merge([noMethodVisitor, {
|
||||
Super(path) {
|
||||
Super(path, state) {
|
||||
if (
|
||||
this.isDerived && !this.hasBareSuper &&
|
||||
!path.parentPath.isCallExpression({ callee: path.node })
|
||||
!path.parentPath.isCallExpression({ callee: path.node }) &&
|
||||
!state.inArrowFunctionExpression
|
||||
) {
|
||||
throw path.buildCodeFrameError("'super.*' is not allowed before super()");
|
||||
}
|
||||
},
|
||||
|
||||
ArrowFunctionExpression(path, state) {
|
||||
state.inArrowFunctionExpression = true;
|
||||
},
|
||||
|
||||
CallExpression: {
|
||||
exit(path) {
|
||||
if (path.get("callee").isSuper()) {
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
const t = () => super.test()
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
var Foo = 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", _this).call(_this);
|
||||
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||
}
|
||||
|
||||
return Foo;
|
||||
}(Bar);
|
||||
Loading…
x
Reference in New Issue
Block a user