Skip to content

Commit b13fee5

Browse files
committed
fix: properly wrap private class methods
1 parent 93e7261 commit b13fee5

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

packages/babel-helper-wrap-function/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function plainFunction(path: NodePath, callId: Object) {
124124
}
125125

126126
export default function wrapFunction(path: NodePath, callId: Object) {
127-
if (path.isClassMethod() || path.isObjectMethod()) {
127+
if (path.isMethod()) {
128128
classOrObjectMethod(path, callId);
129129
} else {
130130
plainFunction(path, callId);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class C {
2+
async * #g() {
3+
this;
4+
await 1;
5+
yield 2;
6+
return 3;
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["external-helpers", "proposal-private-methods", "proposal-async-generator-functions"]
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var _g = new WeakSet();
2+
3+
class C {
4+
constructor() {
5+
_g.add(this);
6+
}
7+
8+
}
9+
10+
var _g2 = function _g2() {
11+
var _this = this;
12+
13+
return babelHelpers.wrapAsyncGenerator(function* () {
14+
_this;
15+
yield babelHelpers.awaitAsyncGenerator(1);
16+
yield 2;
17+
return 3;
18+
})();
19+
};

0 commit comments

Comments
 (0)