fix: properly wrap private class methods (#12192)

This commit is contained in:
Huáng Jùnliàng 2020-10-16 10:12:50 -04:00 committed by GitHub
parent 31396b286d
commit a9cd0945b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View File

@ -124,7 +124,7 @@ function plainFunction(path: NodePath, callId: Object) {
}
export default function wrapFunction(path: NodePath, callId: Object) {
if (path.isClassMethod() || path.isObjectMethod()) {
if (path.isMethod()) {
classOrObjectMethod(path, callId);
} else {
plainFunction(path, callId);

View File

@ -0,0 +1,8 @@
class C {
async * #g() {
this;
await 1;
yield 2;
return 3;
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": ["external-helpers", "proposal-private-methods", "proposal-async-generator-functions"]
}

View File

@ -0,0 +1,19 @@
var _g = new WeakSet();
class C {
constructor() {
_g.add(this);
}
}
var _g2 = function _g2() {
var _this = this;
return babelHelpers.wrapAsyncGenerator(function* () {
_this;
yield babelHelpers.awaitAsyncGenerator(1);
yield 2;
return 3;
})();
};