Wait the correct number of ticks on nested await (#13961)
This commit is contained in:
parent
54c539ecc1
commit
d16f8111ea
@ -19,11 +19,6 @@ const awaitVisitor = {
|
||||
AwaitExpression(path, { wrapAwait }) {
|
||||
const argument = path.get("argument");
|
||||
|
||||
if (path.parentPath.isYieldExpression()) {
|
||||
path.replaceWith(argument.node);
|
||||
return;
|
||||
}
|
||||
|
||||
path.replaceWith(
|
||||
yieldExpression(
|
||||
wrapAwait
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
const log = [];
|
||||
|
||||
const p1 = (async function () {
|
||||
log.push(1);
|
||||
await await null;
|
||||
log.push(2);
|
||||
})();
|
||||
|
||||
const p2 = (async function () {
|
||||
log.push(3);
|
||||
await null;
|
||||
log.push(4);
|
||||
})();
|
||||
|
||||
log.push(5);
|
||||
const p3 = Promise.resolve().then(() => log.push(6)).then(() => log.push(7));
|
||||
|
||||
return Promise.all([p1, p2, p3]).then(() => {
|
||||
expect(log).toEqual([1, 3, 5, 4, 6, 2, 7]);
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
async function fn() {
|
||||
await await 1;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
{
|
||||
"parserOpts": {
|
||||
"allowReturnOutsideFunction": true
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
function fn() {
|
||||
return _fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _fn() {
|
||||
_fn = babelHelpers.asyncToGenerator(function* () {
|
||||
yield yield 1;
|
||||
});
|
||||
return _fn.apply(this, arguments);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user