Fix optional method chaining in derived classes (#10694)
This commit is contained in:
parent
d9fd07929a
commit
ecad667dda
@ -82,6 +82,8 @@ export default declare((api, options) => {
|
||||
let context = scope.maybeGenerateMemoised(object);
|
||||
if (context) {
|
||||
chain.object = t.assignmentExpression("=", context, object);
|
||||
} else if (t.isSuper(object)) {
|
||||
context = t.thisExpression();
|
||||
} else {
|
||||
context = object;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
class Base {
|
||||
method() {
|
||||
return 'Hello!';
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
method() {
|
||||
return super.method?.()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["proposal-optional-chaining", { "loose": true }]]
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
class Base {
|
||||
method() {
|
||||
return 'Hello!';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
method() {
|
||||
return super.method == null ? void 0 : super.method();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
class Base {
|
||||
method() {
|
||||
return 'Hello!';
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
method() {
|
||||
return super.method?.()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
class Base {
|
||||
method() {
|
||||
return 'Hello!';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
method() {
|
||||
var _super$method;
|
||||
|
||||
return (_super$method = super.method) === null || _super$method === void 0 ? void 0 : _super$method.call(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user