Debian Codegraph @

packages/babel-plugin-transform-for-of/src/index.ts

raw symbols SCIP
1 import { declarescip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/declare(). } from "@babel/helper-plugin-utils"scip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/;
2 import { template, types as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/ } from "@babel/core"scip-typescript npm @babel/core 7.20.12 src/`index.ts`/;
3 import type { NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# } from "@babel/traverse"scip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/;
4
5 import transformWithoutHelperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`no-helper-implementation.ts`/transformWithoutHelper(). from "./no-helper-implementation"scip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`no-helper-implementation.ts`/;
6
7 export interface Optionsscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options# {
8 allowArrayLikescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#allowArrayLike.?: boolean;
9 assumeArrayscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#assumeArray.?: boolean;
10 loosescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#loose.?: boolean;
11 }
12
13 function buildLoopBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(
14 pathscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path): NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForXStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForXStatement#>,
15 declarscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(declar): tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Statementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Statement#,
16 newBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(newBody)?: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Statementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Statement# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Expressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Expression#,
17 ) {
18 let block;
19 const bodyPath = pathscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path).get("body");
20 const body = newBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(newBody) ?? bodyPath.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
21 if (
22 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isBlockStatementscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isBlockStatement().(body) &&
23 Objectscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Object#.keysscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/ObjectConstructor#keys().(pathscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path).getBindingIdentifiers()).somescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#some().(id =>
24 bodyPath.scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope..hasOwnBindingscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#hasOwnBinding().(id),
25 )
26 ) {
27 block = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.blockStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/blockStatement().([declarscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(declar), body]);
28 } else {
29 block = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.toBlock(body);
30 block.bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BlockStatement#body..unshiftscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#unshift().(declarscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(declar));
31 }
32 return block;
33 }
34
35 export default declarescip-typescript npm @babel/helper-plugin-utils 7.20.2 src/`index.ts`/declare().((api, options: Optionsscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#) => {
36 api.assertVersionscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:assertVersion.(7);
37
38 {
39 const { assumeArrayscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#assumeArray., allowArrayLikescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#allowArrayLike., loosescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#loose. } = options;
40
41 if (loose === true && assumeArray === true) {
42 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
43 `The loose and assumeArray options cannot be used together in @babel/plugin-transform-for-of`,
44 );
45 }
46
47 if (assumeArray === true && allowArrayLike === true) {
48 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
49 `The assumeArray and allowArrayLike options cannot be used together in @babel/plugin-transform-for-of`,
50 );
51 }
52
53 // TODO: Remove in Babel 8
54 if (allowArrayLike && /^7\.\d\./.testscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/RegExp#test().(api.versionscip-typescript npm @babel/core 7.20.12 src/config/helpers/`config-api.ts`/ConfigAPI#typeLiteral7:version.)) {
55 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
56 `The allowArrayLike is only supported when using @babel/core@^7.10.0`,
57 );
58 }
59 }
60
61 const iterableIsArray =
62 options.assumeArrayscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#assumeArray. ??
63 // Loose mode is not compatible with 'assumeArray', so we shouldn't read
64 // 'iterableIsArray' if 'loose' is true.
65 (!options.loosescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#loose. && api.assumption("iterableIsArray"));
66
67 const arrayLikeIsIterable =
68 options.allowArrayLikescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#allowArrayLike. ?? api.assumption("arrayLikeIsIterable");
69
70 const skipteratorClosing =
71 api.assumption("skipForOfIteratorClosing") ?? options.loosescip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/Options#loose.;
72
73 if (iterableIsArray && arrayLikeIsIterable) {
74 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
75 `The "iterableIsArray" and "arrayLikeIsIterable" assumptions are not compatible.`,
76 );
77 }
78
79 if (iterableIsArray) {
80 return {
81 namescip-typescript npm @babel/core 7.20.12 src/config/validation/`plugins.ts`/PluginObject#typeLiteral0:name.: "transform-for-of",
82
83 visitorscip-typescript npm @babel/core 7.20.12 src/config/validation/`plugins.ts`/PluginObject#typeLiteral0:visitor.: {
84 ForOfStatement(path) {
85 const { scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
86 const { leftscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#left., rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#right., awaitscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#await.: isAwait } = path.nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node.;
87 if (isAwait) {
88 return;
89 }
90 const i = scope.generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().("i");
91 let array: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ThisExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ThisExpression# =
92 scope.maybeGenerateMemoisedscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#maybeGenerateMemoised().(right, true);
93
94 const inits = [tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.variableDeclaratorscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclarator().(i, tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.numericLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/numericLiteral().(0))];
95 if (array) {
96 inits.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().(tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.variableDeclaratorscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclarator().(array, right));
97 } else {
98 array = right as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Identifierscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Identifier# | tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ThisExpressionscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ThisExpression#;
99 }
100
101 const item = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(
102 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(array),
103 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(i),
104 true,
105 );
106 let assignment;
107 if (tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isVariableDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isVariableDeclaration().(left)) {
108 assignment = left;
109 assignment.declarationsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#declarations.[0].initscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclarator#init. = item;
110 } else {
111 assignment = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.expressionStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/expressionStatement().(
112 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", left, item),
113 );
114 }
115
116 path.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(
117 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.forStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/forStatement().(
118 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.variableDeclarationscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclaration().("let", inits),
119 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.binaryExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/binaryExpression().(
120 "<",
121 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(i),
122 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(array), tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("length")),
123 ),
124 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.updateExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/updateExpression().("++", tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(i)),
125 buildLoopBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path, assignment),
126 ),
127 );
128 },
129 },
130 };
131 }
132
133 const buildForOfArray = template`
134 for (var KEY = 0, NAME = ARR; KEY < NAME.length; KEY++) BODY;
135 `;
136
137 const buildForOfNoIteratorClosing = template.statementsscip-typescript npm @babel/template 7.20.7 src/`index.ts`/statements0:`
138 for (var ITERATOR_HELPER = CREATE_ITERATOR_HELPER(OBJECT, ARRAY_LIKE_IS_ITERABLE), STEP_KEY;
139 !(STEP_KEY = ITERATOR_HELPER()).done;) BODY;
140 `;
141
142 const buildForOf = template.statementsscip-typescript npm @babel/template 7.20.7 src/`index.ts`/statements0:`
143 var ITERATOR_HELPER = CREATE_ITERATOR_HELPER(OBJECT, ARRAY_LIKE_IS_ITERABLE), STEP_KEY;
144 try {
145 for (ITERATOR_HELPER.s(); !(STEP_KEY = ITERATOR_HELPER.n()).done;) BODY;
146 } catch (err) {
147 ITERATOR_HELPER.e(err);
148 } finally {
149 ITERATOR_HELPER.f();
150 }
151 `;
152
153 const builder = skipteratorClosing
154 ? {
155 buildscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/build0:: buildForOfNoIteratorClosing,
156 helperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/helper0:: "createForOfIteratorHelperLoose",
157 getContainerscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/getContainer0:: (nodes: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Statementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Statement#[]): [tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForStatement#] =>
158 nodes as [tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForStatement#],
159 }
160 : {
161 buildscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/build1:: buildForOf,
162 helperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/helper1:: "createForOfIteratorHelper",
163 getContainerscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/getContainer1:: (nodes: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Statementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Statement#[]): [tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForStatement#] =>
164 (nodes[1] as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.TryStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/TryStatement#).blockscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/TryStatement#block..bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/BlockStatement#body. as [tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForStatement#],
165 };
166
167 function _ForOfStatementArray(path: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ForOfStatementscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#>) {
168 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
169
170 const right = scope.generateUidIdentifierBasedOnNodescip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifierBasedOnNode().(node.rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#right., "arr");
171 const iterationKey = scope.generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().("i");
172
173 const loop = buildForOfArray({
174 BODYscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/BODY0:: node.bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#body.,
175 KEYscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/KEY0:: iterationKey,
176 NAMEscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/NAME0:: right,
177 ARRscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/ARR0:: node.rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#right.,
178 }) as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Forscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/For#;
179
180 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.inherits(loop, node);
181
182 const iterationValue = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(
183 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(right),
184 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.cloneNode(iterationKey),
185 true,
186 );
187
188 let declar;
189 const left = node.leftscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#left.;
190 if (tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isVariableDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isVariableDeclaration().(left)) {
191 left.declarationsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#declarations.[0].initscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclarator#init. = iterationValue;
192 declar = left;
193 } else {
194 declar = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.expressionStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/expressionStatement().(
195 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", left, iterationValue),
196 );
197 }
198
199 loop.bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForInStatement#body. = buildLoopBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path, declar, loop.bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForInStatement#body.);
200
201 return loop;
202 }
203
204 return {
205 namescip-typescript npm @babel/core 7.20.12 src/config/validation/`plugins.ts`/PluginObject#typeLiteral0:name.: "transform-for-of",
206 visitorscip-typescript npm @babel/core 7.20.12 src/config/validation/`plugins.ts`/PluginObject#typeLiteral0:visitor.: {
207 ForOfStatement(path, state) {
208 const right = path.get("right");
209 if (
210 right.isArrayExpressionscip-typescript npm @babel/traverse 7.20.13 src/path/generated/`validators.d.ts`/BaseNodePathValidators#isArrayExpression().() ||
211 (process.env.BABEL_8_BREAKING
212 ? right.isGenericTypescip-typescript npm @babel/traverse 7.20.13 src/path/inference/`index.ts`/isGenericType().("Array")
213 : right.isGenericTypescip-typescript npm @babel/traverse 7.20.13 src/path/inference/`index.ts`/isGenericType().("Array") ||
214 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isArrayTypeAnnotationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isArrayTypeAnnotation().(right.getTypeAnnotationscip-typescript npm @babel/traverse 7.20.13 src/path/inference/`index.ts`/getTypeAnnotation().()))
215 ) {
216 path.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(_ForOfStatementArray(path));
217 return;
218 }
219
220 if (!state.availableHelperscip-typescript npm @babel/core 7.20.12 src/transformation/`plugin-pass.ts`/PluginPass#availableHelper().(builder.helperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/helper0:)) {
221 // Babel <7.9.0 doesn't support this helper
222 transformWithoutHelperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`no-helper-implementation.ts`/transformWithoutHelper().(skipteratorClosing, path, state);
223 return;
224 }
225
226 const { nodescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#node., parentscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parent., scopescip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#scope. } = path;
227 const left = node.leftscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#left.;
228 let declar;
229
230 const stepKey = scope.generateUidscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUid().("step");
231 const stepValue = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.memberExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/memberExpression().(
232 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().(stepKey),
233 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().("value"),
234 );
235
236 if (tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isVariableDeclarationscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isVariableDeclaration().(left)) {
237 // for (let i of test)
238 declar = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.variableDeclarationscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclaration().(left.kindscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#kind., [
239 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.variableDeclaratorscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/variableDeclarator().(left.declarationsscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclaration#declarations.[0].idscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/VariableDeclarator#id., stepValue),
240 ]);
241 } else {
242 // for (i of test), for ({ i } of test)
243 declar = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.expressionStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/expressionStatement().(
244 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.assignmentExpressionscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/assignmentExpression().("=", left, stepValue),
245 );
246 }
247
248 const nodes = builder.buildscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/build0:({
249 CREATE_ITERATOR_HELPERscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/CREATE_ITERATOR_HELPER0:: state.addHelperscip-typescript npm @babel/core 7.20.12 src/transformation/`plugin-pass.ts`/PluginPass#addHelper().(builder.helperscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/helper0:),
250 ITERATOR_HELPERscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/ITERATOR_HELPER0:: scope.generateUidIdentifierscip-typescript npm @babel/traverse 7.20.13 src/scope/`index.ts`/Scope#generateUidIdentifier().("iterator"),
251 ARRAY_LIKE_IS_ITERABLEscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/ARRAY_LIKE_IS_ITERABLE0:: arrayLikeIsIterable
252 ? tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.booleanLiteralscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/booleanLiteral().(true)
253 : null,
254 STEP_KEYscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/STEP_KEY0:: tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.identifierscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/identifier().(stepKey),
255 OBJECTscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/OBJECT0:: node.rightscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#right.,
256 BODYscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/BODY1:: buildLoopBodyscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/buildLoopBody().(path, declar),
257 });
258 const container = builder.getContainerscip-typescript npm @babel/plugin-transform-for-of 7.18.8 src/`index.ts`/getContainer0:(nodes);
259
260 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.inherits(container[0], node);
261 tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.inherits(container[0].bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForStatement#body., node.bodyscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ForOfStatement#body.);
262
263 if (tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.isLabeledStatementscip-typescript npm @babel/types 7.20.7 src/validators/generated/`index.ts`/isLabeledStatement().(parent)) {
264 // @ts-expect-error replacing node types
265 container[0] = tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.labeledStatementscip-typescript npm @babel/types 7.20.7 src/builders/generated/`index.ts`/labeledStatement().(parent.labelscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/LabeledStatement#label., container[0]);
266
267 path.parentPathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#parentPath..replaceWithMultiplescip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWithMultiple().(nodes);
268
269 // The parent has been replaced, prevent Babel from traversing a detatched path
270 path.skipscip-typescript npm @babel/traverse 7.20.13 src/path/`context.ts`/skip().();
271 } else {
272 path.replaceWithMultiplescip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWithMultiple().(nodes);
273 }
274 },
275 },
276 };
277 });