diff --git a/packages/babel-plugin-transform-for-of/src/index.ts b/packages/babel-plugin-transform-for-of/src/index.ts index 1ba8fb9add42..b940c4c16baa 100644 --- a/packages/babel-plugin-transform-for-of/src/index.ts +++ b/packages/babel-plugin-transform-for-of/src/index.ts @@ -206,9 +206,9 @@ export default declare((api, options: Options) => { const right = path.get("right"); if ( right.isArrayExpression() || - right.isGenericType("Array") || - // todo(Babel 8): the following line can be removed as it is supported by isGenericType("Array") - t.isArrayTypeAnnotation(right.getTypeAnnotation()) + (process.env.BABEL_8_BREAKING + ? right.isGenericType("Array") + : right.isGenericType("Array") || t.isArrayTypeAnnotation(right.getTypeAnnotation())) ) { path.replaceWith(_ForOfStatementArray(path)); return;