fix: for-of transform should skip for-await-of (#11023)
This commit is contained in:
parent
3daab41e61
commit
06dace1cdb
@ -19,7 +19,10 @@ export default declare((api, options) => {
|
|||||||
visitor: {
|
visitor: {
|
||||||
ForOfStatement(path) {
|
ForOfStatement(path) {
|
||||||
const { scope } = path;
|
const { scope } = path;
|
||||||
const { left, right, body } = path.node;
|
const { left, right, body, await: isAwait } = path.node;
|
||||||
|
if (isAwait) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const i = scope.generateUidIdentifier("i");
|
const i = scope.generateUidIdentifier("i");
|
||||||
let array = scope.maybeGenerateMemoised(right, true);
|
let array = scope.maybeGenerateMemoised(right, true);
|
||||||
|
|
||||||
|
|||||||
1
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/input.js
vendored
Normal file
1
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/input.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
async () => { for await (let foo of []); };
|
||||||
3
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/output.js
vendored
Normal file
3
packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/output.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
async () => {
|
||||||
|
for await (let foo of []);
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user