Merge pull request #2861 from hzoo/i-2838
helper-remap-async-to-generator: account for ObjectMethod - fixes #2838
This commit is contained in:
commit
9a1cf40296
6
packages/babel-core/test/fixtures/transformation/async-to-generator/object-method/actual.js
vendored
Normal file
6
packages/babel-core/test/fixtures/transformation/async-to-generator/object-method/actual.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
let obj = {
|
||||
a: 123,
|
||||
async foo(bar) {
|
||||
return await baz(bar);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
let obj = {
|
||||
a: 123,
|
||||
foo(bar) {
|
||||
return babelHelpers.asyncToGenerator(function* () {
|
||||
return yield baz(bar);
|
||||
})();
|
||||
}
|
||||
};
|
||||
@ -24,7 +24,7 @@ let awaitVisitor = {
|
||||
}
|
||||
};
|
||||
|
||||
function classMethod(path: NodePath, callId: Object) {
|
||||
function classOrObjectMethod(path: NodePath, callId: Object) {
|
||||
let node = path.node;
|
||||
let body = node.body;
|
||||
|
||||
@ -99,8 +99,8 @@ export default function (path: NodePath, callId: Object) {
|
||||
|
||||
path.traverse(awaitVisitor);
|
||||
|
||||
if (path.isClassMethod()) {
|
||||
return classMethod(path, callId);
|
||||
if (path.isClassMethod() || path.isObjectMethod()) {
|
||||
return classOrObjectMethod(path, callId);
|
||||
} else {
|
||||
return plainFunction(path, callId);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user