Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Dec 5, 2023
1 parent 8a2da65 commit c7804e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/babel-plugin-transform-for-of/package.json
Expand Up @@ -17,7 +17,8 @@
"babel-plugin"
],
"dependencies": {
"@babel/helper-plugin-utils": "workspace:^"
"@babel/helper-plugin-utils": "workspace:^",
"@babel/helper-skip-transparent-expression-wrappers": "workspace:^"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
Expand Down
7 changes: 6 additions & 1 deletion packages/babel-plugin-transform-for-of/src/index.ts
Expand Up @@ -3,6 +3,7 @@ import { template, types as t } from "@babel/core";
import type { NodePath } from "@babel/traverse";

import transformWithoutHelper from "./no-helper-implementation.ts";
import { skipTransparentExprWrapperNodes } from "@babel/helper-skip-transparent-expression-wrappers";

export interface Options {
allowArrayLike?: boolean;
Expand Down Expand Up @@ -89,10 +90,14 @@ export default declare((api, options: Options) => {
visitor: {
ForOfStatement(path) {
const { scope } = path;
const { left, right, await: isAwait } = path.node;
const { left, await: isAwait } = path.node;
if (isAwait) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const right = skipTransparentExprWrapperNodes(
path.node.right,
) as t.Expression;
const i = scope.generateUidIdentifier("i");
let array: t.Identifier | t.ThisExpression =
scope.maybeGenerateMemoised(right, true);
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -2724,6 +2724,7 @@ __metadata:
"@babel/core": "workspace:^"
"@babel/helper-plugin-test-runner": "workspace:^"
"@babel/helper-plugin-utils": "workspace:^"
"@babel/helper-skip-transparent-expression-wrappers": "workspace:^"
peerDependencies:
"@babel/core": ^7.0.0-0
languageName: unknown
Expand Down

0 comments on commit c7804e8

Please sign in to comment.