diff --git a/packages/babel-plugin-transform-for-of/src/index.js b/packages/babel-plugin-transform-for-of/src/index.js index cd4c6e17bcd5..85d6034f3ffd 100644 --- a/packages/babel-plugin-transform-for-of/src/index.js +++ b/packages/babel-plugin-transform-for-of/src/index.js @@ -19,7 +19,10 @@ export default declare((api, options) => { visitor: { ForOfStatement(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"); let array = scope.maybeGenerateMemoised(right, true); diff --git a/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/input.js b/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/input.js new file mode 100644 index 000000000000..623d204b34cb --- /dev/null +++ b/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/input.js @@ -0,0 +1 @@ +async () => { for await (let foo of []); }; diff --git a/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/output.js b/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/output.js new file mode 100644 index 000000000000..03379d55586f --- /dev/null +++ b/packages/babel-plugin-transform-for-of/test/fixtures/for-of-as-array/for-await-of/output.js @@ -0,0 +1,3 @@ +async () => { + for await (let foo of []); +};