@graphcommerce/next-config 9.0.4-canary.8 → 9.1.0-canary.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/__tests__/config/utils/mergeEnvIntoConfig.ts +12 -1
  3. package/__tests__/config/utils/replaceConfigInString.ts +0 -1
  4. package/__tests__/interceptors/findPlugins.ts +301 -254
  5. package/__tests__/utils/resolveDependenciesSync.ts +44 -44
  6. package/dist/generated/config.js +109 -120
  7. package/dist/index.js +3359 -26
  8. package/package.json +33 -8
  9. package/src/config/commands/generateConfig.ts +16 -4
  10. package/src/config/demoConfig.ts +0 -1
  11. package/src/config/loadConfig.ts +3 -9
  12. package/src/config/utils/mergeEnvIntoConfig.ts +8 -6
  13. package/src/generated/config.ts +11 -5
  14. package/src/interceptors/generateInterceptor.ts +0 -2
  15. package/src/interceptors/parseStructure.ts +3 -3
  16. package/src/utils/resolveDependenciesSync.ts +43 -6
  17. package/src/withGraphCommerce.ts +30 -42
  18. package/tsconfig.json +1 -1
  19. package/__tests__/config/utils/rewriteLegancyEnv.ts +0 -79
  20. package/dist/commands/codegen.js +0 -18
  21. package/dist/commands/copyFiles.js +0 -297
  22. package/dist/config/commands/exportConfig.js +0 -16
  23. package/dist/config/commands/generateConfig.js +0 -56
  24. package/dist/config/demoConfig.js +0 -52
  25. package/dist/config/index.js +0 -19
  26. package/dist/config/loadConfig.js +0 -62
  27. package/dist/config/utils/configToImportMeta.js +0 -39
  28. package/dist/config/utils/diff.js +0 -33
  29. package/dist/config/utils/exportConfigToEnv.js +0 -31
  30. package/dist/config/utils/mergeEnvIntoConfig.js +0 -182
  31. package/dist/config/utils/replaceConfigInString.js +0 -12
  32. package/dist/config/utils/rewriteLegacyEnv.js +0 -115
  33. package/dist/interceptors/InterceptorPlugin.js +0 -108
  34. package/dist/interceptors/RenameVisitor.js +0 -19
  35. package/dist/interceptors/Visitor.js +0 -1414
  36. package/dist/interceptors/commands/codegenInterceptors.js +0 -22
  37. package/dist/interceptors/extractExports.js +0 -159
  38. package/dist/interceptors/findOriginalSource.js +0 -103
  39. package/dist/interceptors/findPlugins.js +0 -68
  40. package/dist/interceptors/generateInterceptor.js +0 -219
  41. package/dist/interceptors/generateInterceptors.js +0 -56
  42. package/dist/interceptors/parseStructure.js +0 -84
  43. package/dist/interceptors/swc.js +0 -15
  44. package/dist/interceptors/writeInterceptors.js +0 -44
  45. package/dist/utils/PackagesSort.js +0 -7
  46. package/dist/utils/TopologicalSort.js +0 -87
  47. package/dist/utils/isMonorepo.js +0 -47
  48. package/dist/utils/packageRoots.js +0 -31
  49. package/dist/utils/resolveDependenciesSync.js +0 -78
  50. package/dist/utils/resolveDependency.js +0 -70
  51. package/dist/utils/sig.js +0 -34
  52. package/dist/withGraphCommerce.js +0 -162
  53. package/src/config/utils/rewriteLegacyEnv.ts +0 -125
@@ -1,1414 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Visitor = void 0;
4
- /* eslint-disable no-param-reassign */
5
- /* eslint-disable class-methods-use-this */
6
- /* eslint-disable consistent-return */
7
- /**
8
- * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
9
- * @public
10
- */
11
- class Visitor {
12
- visitProgram(n) {
13
- switch (n.type) {
14
- case 'Module':
15
- return this.visitModule(n);
16
- case 'Script':
17
- return this.visitScript(n);
18
- }
19
- }
20
- visitModule(m) {
21
- m.body = this.visitModuleItems(m.body);
22
- return m;
23
- }
24
- visitScript(m) {
25
- m.body = this.visitStatements(m.body);
26
- return m;
27
- }
28
- visitModuleItems(items) {
29
- return items.map(this.visitModuleItem.bind(this));
30
- }
31
- visitModuleItem(n) {
32
- switch (n.type) {
33
- case 'ExportDeclaration':
34
- case 'ExportDefaultDeclaration':
35
- case 'ExportNamedDeclaration':
36
- case 'ExportDefaultExpression':
37
- case 'ImportDeclaration':
38
- case 'ExportAllDeclaration':
39
- case 'TsImportEqualsDeclaration':
40
- case 'TsExportAssignment':
41
- case 'TsNamespaceExportDeclaration':
42
- return this.visitModuleDeclaration(n);
43
- default:
44
- return this.visitStatement(n);
45
- }
46
- }
47
- visitModuleDeclaration(n) {
48
- switch (n.type) {
49
- case 'ExportDeclaration':
50
- return this.visitExportDeclaration(n);
51
- case 'ExportDefaultDeclaration':
52
- return this.visitExportDefaultDeclaration(n);
53
- case 'ExportNamedDeclaration':
54
- return this.visitExportNamedDeclaration(n);
55
- case 'ExportDefaultExpression':
56
- return this.visitExportDefaultExpression(n);
57
- case 'ImportDeclaration':
58
- return this.visitImportDeclaration(n);
59
- case 'ExportAllDeclaration':
60
- return this.visitExportAllDeclaration(n);
61
- case 'TsImportEqualsDeclaration':
62
- return this.visitTsImportEqualsDeclaration(n);
63
- case 'TsExportAssignment':
64
- return this.visitTsExportAssignment(n);
65
- case 'TsNamespaceExportDeclaration':
66
- return this.visitTsNamespaceExportDeclaration(n);
67
- }
68
- }
69
- visitTsNamespaceExportDeclaration(n) {
70
- n.id = this.visitBindingIdentifier(n.id);
71
- return n;
72
- }
73
- visitTsExportAssignment(n) {
74
- n.expression = this.visitExpression(n.expression);
75
- return n;
76
- }
77
- visitTsImportEqualsDeclaration(n) {
78
- n.id = this.visitBindingIdentifier(n.id);
79
- n.moduleRef = this.visitTsModuleReference(n.moduleRef);
80
- return n;
81
- }
82
- visitTsModuleReference(n) {
83
- switch (n.type) {
84
- case 'Identifier':
85
- return this.visitIdentifierReference(n);
86
- case 'TsExternalModuleReference':
87
- return this.visitTsExternalModuleReference(n);
88
- case 'TsQualifiedName':
89
- return this.visitTsQualifiedName(n);
90
- }
91
- }
92
- visitTsExternalModuleReference(n) {
93
- n.expression = this.visitStringLiteral(n.expression);
94
- return n;
95
- }
96
- visitExportAllDeclaration(n) {
97
- n.source = this.visitStringLiteral(n.source);
98
- return n;
99
- }
100
- visitExportDefaultExpression(n) {
101
- n.expression = this.visitExpression(n.expression);
102
- return n;
103
- }
104
- visitExportNamedDeclaration(n) {
105
- n.specifiers = this.visitExportSpecifiers(n.specifiers);
106
- n.source = this.visitOptionalStringLiteral(n.source);
107
- return n;
108
- }
109
- visitExportSpecifiers(nodes) {
110
- return nodes.map(this.visitExportSpecifier.bind(this));
111
- }
112
- visitExportSpecifier(n) {
113
- switch (n.type) {
114
- case 'ExportDefaultSpecifier':
115
- return this.visitExportDefaultSpecifier(n);
116
- case 'ExportNamespaceSpecifier':
117
- return this.visitExportNamespaceSpecifier(n);
118
- case 'ExportSpecifier':
119
- return this.visitNamedExportSpecifier(n);
120
- }
121
- }
122
- visitNamedExportSpecifier(n) {
123
- if (n.exported) {
124
- n.exported = this.visitModuleExportName(n.exported);
125
- }
126
- n.orig = this.visitModuleExportName(n.orig);
127
- return n;
128
- }
129
- visitModuleExportName(n) {
130
- switch (n.type) {
131
- case 'Identifier':
132
- return this.visitIdentifier(n);
133
- case 'StringLiteral':
134
- return this.visitStringLiteral(n);
135
- }
136
- }
137
- visitExportNamespaceSpecifier(n) {
138
- n.name = this.visitModuleExportName(n.name);
139
- return n;
140
- }
141
- visitExportDefaultSpecifier(n) {
142
- n.exported = this.visitBindingIdentifier(n.exported);
143
- return n;
144
- }
145
- visitOptionalStringLiteral(n) {
146
- if (n) {
147
- return this.visitStringLiteral(n);
148
- }
149
- }
150
- visitExportDefaultDeclaration(n) {
151
- n.decl = this.visitDefaultDeclaration(n.decl);
152
- return n;
153
- }
154
- visitDefaultDeclaration(n) {
155
- switch (n.type) {
156
- case 'ClassExpression':
157
- return this.visitClassExpression(n);
158
- case 'FunctionExpression':
159
- return this.visitFunctionExpression(n);
160
- case 'TsInterfaceDeclaration':
161
- return this.visitTsInterfaceDeclaration(n);
162
- }
163
- }
164
- visitFunctionExpression(n) {
165
- n = this.visitFunction(n);
166
- if (n.identifier) {
167
- n.identifier = this.visitBindingIdentifier(n.identifier);
168
- }
169
- return n;
170
- }
171
- visitClassExpression(n) {
172
- n = this.visitClass(n);
173
- if (n.identifier) {
174
- n.identifier = this.visitBindingIdentifier(n.identifier);
175
- }
176
- return n;
177
- }
178
- visitExportDeclaration(n) {
179
- n.declaration = this.visitDeclaration(n.declaration);
180
- return n;
181
- }
182
- visitArrayExpression(e) {
183
- if (e.elements) {
184
- e.elements = e.elements.map(this.visitArrayElement.bind(this));
185
- }
186
- return e;
187
- }
188
- visitArrayElement(e) {
189
- if (e) {
190
- return this.visitExprOrSpread(e);
191
- }
192
- }
193
- visitExprOrSpread(e) {
194
- return {
195
- ...e,
196
- expression: this.visitExpression(e.expression),
197
- };
198
- }
199
- visitExprOrSpreads(nodes) {
200
- return nodes.map(this.visitExprOrSpread.bind(this));
201
- }
202
- visitSpreadElement(e) {
203
- e.arguments = this.visitExpression(e.arguments);
204
- return e;
205
- }
206
- visitOptionalExpression(e) {
207
- if (e) {
208
- return this.visitExpression(e);
209
- }
210
- }
211
- visitArrowFunctionExpression(e) {
212
- e.body = this.visitArrowBody(e.body);
213
- e.params = this.visitPatterns(e.params);
214
- e.returnType = this.visitTsTypeAnnotation(e.returnType);
215
- e.typeParameters = this.visitTsTypeParameterDeclaration(e.typeParameters);
216
- return e;
217
- }
218
- visitArrowBody(body) {
219
- switch (body.type) {
220
- case 'BlockStatement':
221
- return this.visitBlockStatement(body);
222
- default:
223
- return this.visitExpression(body);
224
- }
225
- }
226
- visitBlockStatement(block) {
227
- block.stmts = this.visitStatements(block.stmts);
228
- return block;
229
- }
230
- visitStatements(stmts) {
231
- return stmts.map(this.visitStatement.bind(this));
232
- }
233
- visitStatement(stmt) {
234
- switch (stmt.type) {
235
- case 'ClassDeclaration':
236
- case 'FunctionDeclaration':
237
- case 'TsEnumDeclaration':
238
- case 'TsInterfaceDeclaration':
239
- case 'TsModuleDeclaration':
240
- case 'TsTypeAliasDeclaration':
241
- case 'VariableDeclaration':
242
- return this.visitDeclaration(stmt);
243
- case 'BreakStatement':
244
- return this.visitBreakStatement(stmt);
245
- case 'BlockStatement':
246
- return this.visitBlockStatement(stmt);
247
- case 'ContinueStatement':
248
- return this.visitContinueStatement(stmt);
249
- case 'DebuggerStatement':
250
- return this.visitDebuggerStatement(stmt);
251
- case 'DoWhileStatement':
252
- return this.visitDoWhileStatement(stmt);
253
- case 'EmptyStatement':
254
- return this.visitEmptyStatement(stmt);
255
- case 'ForInStatement':
256
- return this.visitForInStatement(stmt);
257
- case 'ForOfStatement':
258
- return this.visitForOfStatement(stmt);
259
- case 'ForStatement':
260
- return this.visitForStatement(stmt);
261
- case 'IfStatement':
262
- return this.visitIfStatement(stmt);
263
- case 'LabeledStatement':
264
- return this.visitLabeledStatement(stmt);
265
- case 'ReturnStatement':
266
- return this.visitReturnStatement(stmt);
267
- case 'SwitchStatement':
268
- return this.visitSwitchStatement(stmt);
269
- case 'ThrowStatement':
270
- return this.visitThrowStatement(stmt);
271
- case 'TryStatement':
272
- return this.visitTryStatement(stmt);
273
- case 'WhileStatement':
274
- return this.visitWhileStatement(stmt);
275
- case 'WithStatement':
276
- return this.visitWithStatement(stmt);
277
- case 'ExpressionStatement':
278
- return this.visitExpressionStatement(stmt);
279
- default:
280
- throw new Error(`Unknown statement type: ${stmt.type}`);
281
- }
282
- }
283
- visitSwitchStatement(stmt) {
284
- stmt.discriminant = this.visitExpression(stmt.discriminant);
285
- stmt.cases = this.visitSwitchCases(stmt.cases);
286
- return stmt;
287
- }
288
- visitSwitchCases(cases) {
289
- return cases.map(this.visitSwitchCase.bind(this));
290
- }
291
- visitSwitchCase(c) {
292
- c.test = this.visitOptionalExpression(c.test);
293
- c.consequent = this.visitStatements(c.consequent);
294
- return c;
295
- }
296
- visitIfStatement(stmt) {
297
- stmt.test = this.visitExpression(stmt.test);
298
- stmt.consequent = this.visitStatement(stmt.consequent);
299
- stmt.alternate = this.visitOptionalStatement(stmt.alternate);
300
- return stmt;
301
- }
302
- visitOptionalStatement(stmt) {
303
- if (stmt) {
304
- return this.visitStatement(stmt);
305
- }
306
- }
307
- visitBreakStatement(stmt) {
308
- if (stmt.label) {
309
- stmt.label = this.visitLabelIdentifier(stmt.label);
310
- }
311
- return stmt;
312
- }
313
- visitWhileStatement(stmt) {
314
- stmt.test = this.visitExpression(stmt.test);
315
- stmt.body = this.visitStatement(stmt.body);
316
- return stmt;
317
- }
318
- visitTryStatement(stmt) {
319
- stmt.block = this.visitBlockStatement(stmt.block);
320
- stmt.handler = this.visitCatchClause(stmt.handler);
321
- if (stmt.finalizer) {
322
- stmt.finalizer = this.visitBlockStatement(stmt.finalizer);
323
- }
324
- return stmt;
325
- }
326
- visitCatchClause(handler) {
327
- if (handler) {
328
- if (handler.param) {
329
- handler.param = this.visitPattern(handler.param);
330
- }
331
- handler.body = this.visitBlockStatement(handler.body);
332
- }
333
- return handler;
334
- }
335
- visitThrowStatement(stmt) {
336
- stmt.argument = this.visitExpression(stmt.argument);
337
- return stmt;
338
- }
339
- visitReturnStatement(stmt) {
340
- if (stmt.argument) {
341
- stmt.argument = this.visitExpression(stmt.argument);
342
- }
343
- return stmt;
344
- }
345
- visitLabeledStatement(stmt) {
346
- stmt.label = this.visitLabelIdentifier(stmt.label);
347
- stmt.body = this.visitStatement(stmt.body);
348
- return stmt;
349
- }
350
- visitForStatement(stmt) {
351
- if (stmt.init) {
352
- if (stmt.init.type === 'VariableDeclaration') {
353
- stmt.init = this.visitVariableDeclaration(stmt.init);
354
- }
355
- else {
356
- stmt.init = this.visitOptionalExpression(stmt.init);
357
- }
358
- }
359
- stmt.test = this.visitOptionalExpression(stmt.test);
360
- stmt.update = this.visitOptionalExpression(stmt.update);
361
- stmt.body = this.visitStatement(stmt.body);
362
- return stmt;
363
- }
364
- visitForOfStatement(stmt) {
365
- if (stmt.left.type === 'VariableDeclaration') {
366
- stmt.left = this.visitVariableDeclaration(stmt.left);
367
- }
368
- else {
369
- stmt.left = this.visitPattern(stmt.left);
370
- }
371
- stmt.right = this.visitExpression(stmt.right);
372
- stmt.body = this.visitStatement(stmt.body);
373
- return stmt;
374
- }
375
- visitForInStatement(stmt) {
376
- if (stmt.left.type === 'VariableDeclaration') {
377
- stmt.left = this.visitVariableDeclaration(stmt.left);
378
- }
379
- else {
380
- stmt.left = this.visitPattern(stmt.left);
381
- }
382
- stmt.right = this.visitExpression(stmt.right);
383
- stmt.body = this.visitStatement(stmt.body);
384
- return stmt;
385
- }
386
- visitEmptyStatement(stmt) {
387
- return stmt;
388
- }
389
- visitDoWhileStatement(stmt) {
390
- stmt.body = this.visitStatement(stmt.body);
391
- stmt.test = this.visitExpression(stmt.test);
392
- return stmt;
393
- }
394
- visitDebuggerStatement(stmt) {
395
- return stmt;
396
- }
397
- visitWithStatement(stmt) {
398
- stmt.object = this.visitExpression(stmt.object);
399
- stmt.body = this.visitStatement(stmt.body);
400
- return stmt;
401
- }
402
- visitDeclaration(decl) {
403
- switch (decl.type) {
404
- case 'ClassDeclaration':
405
- return this.visitClassDeclaration(decl);
406
- case 'FunctionDeclaration':
407
- return this.visitFunctionDeclaration(decl);
408
- case 'TsEnumDeclaration':
409
- return this.visitTsEnumDeclaration(decl);
410
- case 'TsInterfaceDeclaration':
411
- return this.visitTsInterfaceDeclaration(decl);
412
- case 'TsModuleDeclaration':
413
- return this.visitTsModuleDeclaration(decl);
414
- case 'TsTypeAliasDeclaration':
415
- return this.visitTsTypeAliasDeclaration(decl);
416
- case 'VariableDeclaration':
417
- return this.visitVariableDeclaration(decl);
418
- }
419
- }
420
- visitVariableDeclaration(n) {
421
- n.declarations = this.visitVariableDeclarators(n.declarations);
422
- return n;
423
- }
424
- visitVariableDeclarators(nodes) {
425
- return nodes.map(this.visitVariableDeclarator.bind(this));
426
- }
427
- visitVariableDeclarator(n) {
428
- n.id = this.visitPattern(n.id);
429
- n.init = this.visitOptionalExpression(n.init);
430
- return n;
431
- }
432
- visitTsTypeAliasDeclaration(n) {
433
- n.id = this.visitBindingIdentifier(n.id);
434
- n.typeAnnotation = this.visitTsType(n.typeAnnotation);
435
- n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams);
436
- return n;
437
- }
438
- visitTsModuleDeclaration(n) {
439
- n.id = this.visitTsModuleName(n.id);
440
- if (n.body) {
441
- n.body = this.visitTsNamespaceBody(n.body);
442
- }
443
- return n;
444
- }
445
- visitTsModuleName(n) {
446
- switch (n.type) {
447
- case 'Identifier':
448
- return this.visitBindingIdentifier(n);
449
- case 'StringLiteral':
450
- return this.visitStringLiteral(n);
451
- }
452
- }
453
- visitTsNamespaceBody(n) {
454
- if (n) {
455
- switch (n.type) {
456
- case 'TsModuleBlock':
457
- return this.visitTsModuleBlock(n);
458
- case 'TsNamespaceDeclaration':
459
- return this.visitTsNamespaceDeclaration(n);
460
- }
461
- }
462
- }
463
- visitTsNamespaceDeclaration(n) {
464
- const body = this.visitTsNamespaceBody(n.body);
465
- if (body) {
466
- n.body = body;
467
- }
468
- n.id = this.visitBindingIdentifier(n.id);
469
- return n;
470
- }
471
- visitTsModuleBlock(n) {
472
- n.body = this.visitModuleItems(n.body);
473
- return n;
474
- }
475
- visitTsInterfaceDeclaration(n) {
476
- n.id = this.visitBindingIdentifier(n.id);
477
- n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams);
478
- n.extends = this.visitTsExpressionsWithTypeArguments(n.extends);
479
- n.body = this.visitTsInterfaceBody(n.body);
480
- return n;
481
- }
482
- visitTsInterfaceBody(n) {
483
- n.body = this.visitTsTypeElements(n.body);
484
- return n;
485
- }
486
- visitTsTypeElements(nodes) {
487
- return nodes.map(this.visitTsTypeElement.bind(this));
488
- }
489
- visitTsTypeElement(n) {
490
- switch (n.type) {
491
- case 'TsCallSignatureDeclaration':
492
- return this.visitTsCallSignatureDeclaration(n);
493
- case 'TsConstructSignatureDeclaration':
494
- return this.visitTsConstructSignatureDeclaration(n);
495
- case 'TsPropertySignature':
496
- return this.visitTsPropertySignature(n);
497
- case 'TsGetterSignature':
498
- return this.visitTsGetterSignature(n);
499
- case 'TsSetterSignature':
500
- return this.visitTsSetterSignature(n);
501
- case 'TsMethodSignature':
502
- return this.visitTsMethodSignature(n);
503
- case 'TsIndexSignature':
504
- return this.visitTsIndexSignature(n);
505
- }
506
- }
507
- visitTsCallSignatureDeclaration(n) {
508
- n.params = this.visitTsFnParameters(n.params);
509
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
510
- return n;
511
- }
512
- visitTsConstructSignatureDeclaration(n) {
513
- n.params = this.visitTsFnParameters(n.params);
514
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
515
- return n;
516
- }
517
- visitTsPropertySignature(n) {
518
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
519
- return n;
520
- }
521
- visitTsGetterSignature(n) {
522
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
523
- return n;
524
- }
525
- visitTsSetterSignature(n) {
526
- n.param = this.visitTsFnParameter(n.param);
527
- return n;
528
- }
529
- visitTsMethodSignature(n) {
530
- n.params = this.visitTsFnParameters(n.params);
531
- n.typeAnn = this.visitTsTypeAnnotation(n.typeAnn);
532
- return n;
533
- }
534
- visitTsEnumDeclaration(n) {
535
- n.id = this.visitIdentifier(n.id);
536
- n.members = this.visitTsEnumMembers(n.members);
537
- return n;
538
- }
539
- visitTsEnumMembers(nodes) {
540
- return nodes.map(this.visitTsEnumMember.bind(this));
541
- }
542
- visitTsEnumMember(n) {
543
- n.id = this.visitTsEnumMemberId(n.id);
544
- n.init = this.visitOptionalExpression(n.init);
545
- return n;
546
- }
547
- visitTsEnumMemberId(n) {
548
- switch (n.type) {
549
- case 'Identifier':
550
- return this.visitBindingIdentifier(n);
551
- case 'StringLiteral':
552
- return this.visitStringLiteral(n);
553
- }
554
- }
555
- visitFunctionDeclaration(decl) {
556
- decl.identifier = this.visitIdentifier(decl.identifier);
557
- decl = this.visitFunction(decl);
558
- return decl;
559
- }
560
- visitClassDeclaration(decl) {
561
- decl = this.visitClass(decl);
562
- decl.identifier = this.visitIdentifier(decl.identifier);
563
- return decl;
564
- }
565
- visitClassBody(members) {
566
- return members.map(this.visitClassMember.bind(this));
567
- }
568
- visitClassMember(member) {
569
- switch (member.type) {
570
- case 'ClassMethod':
571
- return this.visitClassMethod(member);
572
- case 'ClassProperty':
573
- return this.visitClassProperty(member);
574
- case 'Constructor':
575
- return this.visitConstructor(member);
576
- case 'PrivateMethod':
577
- return this.visitPrivateMethod(member);
578
- case 'PrivateProperty':
579
- return this.visitPrivateProperty(member);
580
- case 'TsIndexSignature':
581
- return this.visitTsIndexSignature(member);
582
- case 'EmptyStatement':
583
- return this.visitEmptyStatement(member);
584
- case 'StaticBlock':
585
- return this.visitStaticBlock(member);
586
- }
587
- }
588
- visitTsIndexSignature(n) {
589
- n.params = this.visitTsFnParameters(n.params);
590
- if (n.typeAnnotation)
591
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
592
- return n;
593
- }
594
- visitTsFnParameters(params) {
595
- return params.map(this.visitTsFnParameter.bind(this));
596
- }
597
- visitTsFnParameter(n) {
598
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
599
- return n;
600
- }
601
- visitPrivateProperty(n) {
602
- n.decorators = this.visitDecorators(n.decorators);
603
- n.key = this.visitPrivateName(n.key);
604
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
605
- n.value = this.visitOptionalExpression(n.value);
606
- return n;
607
- }
608
- visitPrivateMethod(n) {
609
- n.accessibility = this.visitAccessibility(n.accessibility);
610
- n.function = this.visitFunction(n.function);
611
- n.key = this.visitPrivateName(n.key);
612
- return n;
613
- }
614
- visitPrivateName(n) {
615
- return n;
616
- }
617
- visitConstructor(n) {
618
- n.accessibility = this.visitAccessibility(n.accessibility);
619
- n.key = this.visitPropertyName(n.key);
620
- n.params = this.visitConstructorParameters(n.params);
621
- if (n.body) {
622
- n.body = this.visitBlockStatement(n.body);
623
- }
624
- return n;
625
- }
626
- visitConstructorParameters(nodes) {
627
- return nodes.map(this.visitConstructorParameter.bind(this));
628
- }
629
- visitConstructorParameter(n) {
630
- switch (n.type) {
631
- case 'TsParameterProperty':
632
- return this.visitTsParameterProperty(n);
633
- default:
634
- return this.visitParameter(n);
635
- }
636
- }
637
- visitStaticBlock(n) {
638
- n.body = this.visitBlockStatement(n.body);
639
- return n;
640
- }
641
- visitTsParameterProperty(n) {
642
- n.accessibility = this.visitAccessibility(n.accessibility);
643
- n.decorators = this.visitDecorators(n.decorators);
644
- n.param = this.visitTsParameterPropertyParameter(n.param);
645
- return n;
646
- }
647
- visitTsParameterPropertyParameter(n) {
648
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
649
- return n;
650
- }
651
- visitPropertyName(key) {
652
- switch (key.type) {
653
- case 'Identifier':
654
- return this.visitBindingIdentifier(key);
655
- case 'StringLiteral':
656
- return this.visitStringLiteral(key);
657
- case 'NumericLiteral':
658
- return this.visitNumericLiteral(key);
659
- case 'BigIntLiteral':
660
- return this.visitBigIntLiteral(key);
661
- default:
662
- return this.visitComputedPropertyKey(key);
663
- }
664
- }
665
- visitAccessibility(n) {
666
- return n;
667
- }
668
- visitClassProperty(n) {
669
- n.accessibility = this.visitAccessibility(n.accessibility);
670
- n.decorators = this.visitDecorators(n.decorators);
671
- n.key = this.visitPropertyName(n.key);
672
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
673
- n.value = this.visitOptionalExpression(n.value);
674
- return n;
675
- }
676
- visitClassMethod(n) {
677
- n.accessibility = this.visitAccessibility(n.accessibility);
678
- n.function = this.visitFunction(n.function);
679
- n.key = this.visitPropertyName(n.key);
680
- return n;
681
- }
682
- visitComputedPropertyKey(n) {
683
- n.expression = this.visitExpression(n.expression);
684
- return n;
685
- }
686
- visitClass(n) {
687
- n.decorators = this.visitDecorators(n.decorators);
688
- n.superClass = this.visitOptionalExpression(n.superClass);
689
- n.superTypeParams = this.visitTsTypeParameterInstantiation(n.superTypeParams);
690
- if (n.implements) {
691
- n.implements = this.visitTsExpressionsWithTypeArguments(n.implements);
692
- }
693
- n.body = this.visitClassBody(n.body);
694
- return n;
695
- }
696
- visitFunction(n) {
697
- n.decorators = this.visitDecorators(n.decorators);
698
- n.params = this.visitParameters(n.params);
699
- if (n.body) {
700
- n.body = this.visitBlockStatement(n.body);
701
- }
702
- n.returnType = this.visitTsTypeAnnotation(n.returnType);
703
- n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters);
704
- return n;
705
- }
706
- visitTsExpressionsWithTypeArguments(nodes) {
707
- return nodes.map(this.visitTsExpressionWithTypeArguments.bind(this));
708
- }
709
- visitTsExpressionWithTypeArguments(n) {
710
- n.expression = this.visitExpression(n.expression);
711
- n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
712
- return n;
713
- }
714
- visitTsTypeParameterInstantiation(n) {
715
- if (n) {
716
- n.params = this.visitTsTypes(n.params);
717
- }
718
- return n;
719
- }
720
- visitTsTypes(nodes) {
721
- return nodes.map(this.visitTsType.bind(this));
722
- }
723
- visitTsEntityName(n) {
724
- switch (n.type) {
725
- case 'Identifier':
726
- return this.visitBindingIdentifier(n);
727
- case 'TsQualifiedName':
728
- return this.visitTsQualifiedName(n);
729
- }
730
- }
731
- visitTsQualifiedName(n) {
732
- n.left = this.visitTsEntityName(n.left);
733
- n.right = this.visitIdentifier(n.right);
734
- return n;
735
- }
736
- visitDecorators(nodes) {
737
- if (nodes) {
738
- return nodes.map(this.visitDecorator.bind(this));
739
- }
740
- }
741
- visitDecorator(n) {
742
- n.expression = this.visitExpression(n.expression);
743
- return n;
744
- }
745
- visitExpressionStatement(stmt) {
746
- stmt.expression = this.visitExpression(stmt.expression);
747
- return stmt;
748
- }
749
- visitContinueStatement(stmt) {
750
- if (stmt.label) {
751
- stmt.label = this.visitLabelIdentifier(stmt.label);
752
- }
753
- return stmt;
754
- }
755
- visitExpression(n) {
756
- switch (n.type) {
757
- case 'ArrayExpression':
758
- return this.visitArrayExpression(n);
759
- case 'ArrowFunctionExpression':
760
- return this.visitArrowFunctionExpression(n);
761
- case 'AssignmentExpression':
762
- return this.visitAssignmentExpression(n);
763
- case 'AwaitExpression':
764
- return this.visitAwaitExpression(n);
765
- case 'BigIntLiteral':
766
- return this.visitBigIntLiteral(n);
767
- case 'BinaryExpression':
768
- return this.visitBinaryExpression(n);
769
- case 'BooleanLiteral':
770
- return this.visitBooleanLiteral(n);
771
- case 'CallExpression':
772
- return this.visitCallExpression(n);
773
- case 'ClassExpression':
774
- return this.visitClassExpression(n);
775
- case 'ConditionalExpression':
776
- return this.visitConditionalExpression(n);
777
- case 'FunctionExpression':
778
- return this.visitFunctionExpression(n);
779
- case 'Identifier':
780
- return this.visitIdentifierReference(n);
781
- case 'JSXElement':
782
- return this.visitJSXElement(n);
783
- case 'JSXEmptyExpression':
784
- return this.visitJSXEmptyExpression(n);
785
- case 'JSXFragment':
786
- return this.visitJSXFragment(n);
787
- case 'JSXMemberExpression':
788
- return this.visitJSXMemberExpression(n);
789
- case 'JSXNamespacedName':
790
- return this.visitJSXNamespacedName(n);
791
- case 'JSXText':
792
- return this.visitJSXText(n);
793
- case 'MemberExpression':
794
- return this.visitMemberExpression(n);
795
- case 'SuperPropExpression':
796
- return this.visitSuperPropExpression(n);
797
- case 'MetaProperty':
798
- return this.visitMetaProperty(n);
799
- case 'NewExpression':
800
- return this.visitNewExpression(n);
801
- case 'NullLiteral':
802
- return this.visitNullLiteral(n);
803
- case 'NumericLiteral':
804
- return this.visitNumericLiteral(n);
805
- case 'ObjectExpression':
806
- return this.visitObjectExpression(n);
807
- case 'ParenthesisExpression':
808
- return this.visitParenthesisExpression(n);
809
- case 'PrivateName':
810
- return this.visitPrivateName(n);
811
- case 'RegExpLiteral':
812
- return this.visitRegExpLiteral(n);
813
- case 'SequenceExpression':
814
- return this.visitSequenceExpression(n);
815
- case 'StringLiteral':
816
- return this.visitStringLiteral(n);
817
- case 'TaggedTemplateExpression':
818
- return this.visitTaggedTemplateExpression(n);
819
- case 'TemplateLiteral':
820
- return this.visitTemplateLiteral(n);
821
- case 'ThisExpression':
822
- return this.visitThisExpression(n);
823
- case 'TsAsExpression':
824
- return this.visitTsAsExpression(n);
825
- case 'TsSatisfiesExpression':
826
- return this.visitTsSatisfiesExpression(n);
827
- case 'TsNonNullExpression':
828
- return this.visitTsNonNullExpression(n);
829
- case 'TsTypeAssertion':
830
- return this.visitTsTypeAssertion(n);
831
- case 'TsConstAssertion':
832
- return this.visitTsConstAssertion(n);
833
- case 'TsInstantiation':
834
- return this.visitTsInstantiation(n);
835
- case 'UnaryExpression':
836
- return this.visitUnaryExpression(n);
837
- case 'UpdateExpression':
838
- return this.visitUpdateExpression(n);
839
- case 'YieldExpression':
840
- return this.visitYieldExpression(n);
841
- case 'OptionalChainingExpression':
842
- return this.visitOptionalChainingExpression(n);
843
- case 'Invalid':
844
- return n;
845
- }
846
- }
847
- visitOptionalChainingExpression(n) {
848
- n.base = this.visitMemberExpressionOrOptionalChainingCall(n.base);
849
- return n;
850
- }
851
- visitMemberExpressionOrOptionalChainingCall(n) {
852
- switch (n.type) {
853
- case 'MemberExpression':
854
- return this.visitMemberExpression(n);
855
- case 'CallExpression':
856
- return this.visitOptionalChainingCall(n);
857
- }
858
- }
859
- visitOptionalChainingCall(n) {
860
- n.callee = this.visitExpression(n.callee);
861
- n.arguments = this.visitExprOrSpreads(n.arguments);
862
- if (n.typeArguments)
863
- n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
864
- return n;
865
- }
866
- visitAssignmentExpression(n) {
867
- n.left = this.visitPatternOrExpression(n.left);
868
- n.right = this.visitExpression(n.right);
869
- return n;
870
- }
871
- visitPatternOrExpression(n) {
872
- switch (n.type) {
873
- case 'ObjectPattern':
874
- case 'ArrayPattern':
875
- case 'Identifier':
876
- case 'AssignmentPattern':
877
- case 'RestElement':
878
- return this.visitPattern(n);
879
- default:
880
- return this.visitExpression(n);
881
- }
882
- }
883
- visitYieldExpression(n) {
884
- n.argument = this.visitOptionalExpression(n.argument);
885
- return n;
886
- }
887
- visitUpdateExpression(n) {
888
- n.argument = this.visitExpression(n.argument);
889
- return n;
890
- }
891
- visitUnaryExpression(n) {
892
- n.argument = this.visitExpression(n.argument);
893
- return n;
894
- }
895
- visitTsTypeAssertion(n) {
896
- n.expression = this.visitExpression(n.expression);
897
- n.typeAnnotation = this.visitTsType(n.typeAnnotation);
898
- return n;
899
- }
900
- visitTsConstAssertion(n) {
901
- n.expression = this.visitExpression(n.expression);
902
- return n;
903
- }
904
- visitTsInstantiation(n) {
905
- n.expression = this.visitExpression(n.expression);
906
- return n;
907
- }
908
- visitTsNonNullExpression(n) {
909
- n.expression = this.visitExpression(n.expression);
910
- return n;
911
- }
912
- visitTsAsExpression(n) {
913
- n.expression = this.visitExpression(n.expression);
914
- n.typeAnnotation = this.visitTsType(n.typeAnnotation);
915
- return n;
916
- }
917
- visitTsSatisfiesExpression(n) {
918
- n.expression = this.visitExpression(n.expression);
919
- n.typeAnnotation = this.visitTsType(n.typeAnnotation);
920
- return n;
921
- }
922
- visitThisExpression(n) {
923
- return n;
924
- }
925
- visitTemplateLiteral(n) {
926
- n.expressions = n.expressions.map(this.visitExpression.bind(this));
927
- return n;
928
- }
929
- visitParameters(n) {
930
- return n.map(this.visitParameter.bind(this));
931
- }
932
- visitParameter(n) {
933
- n.pat = this.visitPattern(n.pat);
934
- return n;
935
- }
936
- visitTaggedTemplateExpression(n) {
937
- n.tag = this.visitExpression(n.tag);
938
- const template = this.visitTemplateLiteral(n.template);
939
- if (template.type === 'TemplateLiteral') {
940
- n.template = template;
941
- }
942
- return n;
943
- }
944
- visitSequenceExpression(n) {
945
- n.expressions = n.expressions.map(this.visitExpression.bind(this));
946
- return n;
947
- }
948
- visitRegExpLiteral(n) {
949
- return n;
950
- }
951
- visitParenthesisExpression(n) {
952
- n.expression = this.visitExpression(n.expression);
953
- return n;
954
- }
955
- visitObjectExpression(n) {
956
- if (n.properties) {
957
- n.properties = this.visitObjectProperties(n.properties);
958
- }
959
- return n;
960
- }
961
- visitObjectProperties(nodes) {
962
- return nodes.map(this.visitObjectProperty.bind(this));
963
- }
964
- visitObjectProperty(n) {
965
- switch (n.type) {
966
- case 'SpreadElement':
967
- return this.visitSpreadElement(n);
968
- default:
969
- return this.visitProperty(n);
970
- }
971
- }
972
- visitProperty(n) {
973
- switch (n.type) {
974
- case 'Identifier':
975
- return this.visitIdentifier(n);
976
- case 'AssignmentProperty':
977
- return this.visitAssignmentProperty(n);
978
- case 'GetterProperty':
979
- return this.visitGetterProperty(n);
980
- case 'KeyValueProperty':
981
- return this.visitKeyValueProperty(n);
982
- case 'MethodProperty':
983
- return this.visitMethodProperty(n);
984
- case 'SetterProperty':
985
- return this.visitSetterProperty(n);
986
- }
987
- }
988
- visitSetterProperty(n) {
989
- n.key = this.visitPropertyName(n.key);
990
- n.param = this.visitPattern(n.param);
991
- if (n.body) {
992
- n.body = this.visitBlockStatement(n.body);
993
- }
994
- return n;
995
- }
996
- visitMethodProperty(n) {
997
- n.key = this.visitPropertyName(n.key);
998
- if (n.body) {
999
- n.body = this.visitBlockStatement(n.body);
1000
- }
1001
- n.decorators = this.visitDecorators(n.decorators);
1002
- n.params = this.visitParameters(n.params);
1003
- n.returnType = this.visitTsTypeAnnotation(n.returnType);
1004
- n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters);
1005
- return n;
1006
- }
1007
- visitKeyValueProperty(n) {
1008
- n.key = this.visitPropertyName(n.key);
1009
- n.value = this.visitExpression(n.value);
1010
- return n;
1011
- }
1012
- visitGetterProperty(n) {
1013
- n.key = this.visitPropertyName(n.key);
1014
- if (n.body) {
1015
- n.body = this.visitBlockStatement(n.body);
1016
- }
1017
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1018
- return n;
1019
- }
1020
- visitAssignmentProperty(n) {
1021
- n.key = this.visitIdentifier(n.key);
1022
- n.value = this.visitExpression(n.value);
1023
- return n;
1024
- }
1025
- visitNullLiteral(n) {
1026
- return n;
1027
- }
1028
- visitNewExpression(n) {
1029
- n.callee = this.visitExpression(n.callee);
1030
- if (n.arguments) {
1031
- n.arguments = this.visitArguments(n.arguments);
1032
- }
1033
- n.typeArguments = this.visitTsTypeArguments(n.typeArguments);
1034
- return n;
1035
- }
1036
- visitTsTypeArguments(n) {
1037
- if (n) {
1038
- n.params = this.visitTsTypes(n.params);
1039
- }
1040
- return n;
1041
- }
1042
- visitArguments(nodes) {
1043
- return nodes.map(this.visitArgument.bind(this));
1044
- }
1045
- visitArgument(n) {
1046
- n.expression = this.visitExpression(n.expression);
1047
- return n;
1048
- }
1049
- visitMetaProperty(n) {
1050
- return n;
1051
- }
1052
- visitMemberExpression(n) {
1053
- n.object = this.visitExpression(n.object);
1054
- switch (n.property.type) {
1055
- case 'Computed': {
1056
- n.property = this.visitComputedPropertyKey(n.property);
1057
- return n;
1058
- }
1059
- case 'Identifier': {
1060
- n.property = this.visitIdentifier(n.property);
1061
- return n;
1062
- }
1063
- case 'PrivateName': {
1064
- n.property = this.visitPrivateName(n.property);
1065
- return n;
1066
- }
1067
- }
1068
- }
1069
- visitSuperPropExpression(n) {
1070
- switch (n.property.type) {
1071
- case 'Computed': {
1072
- n.property = this.visitComputedPropertyKey(n.property);
1073
- return n;
1074
- }
1075
- case 'Identifier': {
1076
- n.property = this.visitIdentifier(n.property);
1077
- return n;
1078
- }
1079
- }
1080
- }
1081
- visitCallee(n) {
1082
- if (n.type === 'Super' || n.type === 'Import') {
1083
- return n;
1084
- }
1085
- return this.visitExpression(n);
1086
- }
1087
- visitJSXText(n) {
1088
- return n;
1089
- }
1090
- visitJSXNamespacedName(n) {
1091
- n.namespace = this.visitIdentifierReference(n.namespace);
1092
- n.name = this.visitIdentifierReference(n.name);
1093
- return n;
1094
- }
1095
- visitJSXMemberExpression(n) {
1096
- n.object = this.visitJSXObject(n.object);
1097
- n.property = this.visitIdentifierReference(n.property);
1098
- return n;
1099
- }
1100
- visitJSXObject(n) {
1101
- switch (n.type) {
1102
- case 'Identifier':
1103
- return this.visitIdentifierReference(n);
1104
- case 'JSXMemberExpression':
1105
- return this.visitJSXMemberExpression(n);
1106
- }
1107
- }
1108
- visitJSXFragment(n) {
1109
- n.opening = this.visitJSXOpeningFragment(n.opening);
1110
- if (n.children) {
1111
- n.children = this.visitJSXElementChildren(n.children);
1112
- }
1113
- n.closing = this.visitJSXClosingFragment(n.closing);
1114
- return n;
1115
- }
1116
- visitJSXClosingFragment(n) {
1117
- return n;
1118
- }
1119
- visitJSXElementChildren(nodes) {
1120
- return nodes.map(this.visitJSXElementChild.bind(this));
1121
- }
1122
- visitJSXElementChild(n) {
1123
- switch (n.type) {
1124
- case 'JSXElement':
1125
- return this.visitJSXElement(n);
1126
- case 'JSXExpressionContainer':
1127
- return this.visitJSXExpressionContainer(n);
1128
- case 'JSXFragment':
1129
- return this.visitJSXFragment(n);
1130
- case 'JSXSpreadChild':
1131
- return this.visitJSXSpreadChild(n);
1132
- case 'JSXText':
1133
- return this.visitJSXText(n);
1134
- }
1135
- }
1136
- visitJSXExpressionContainer(n) {
1137
- n.expression = this.visitExpression(n.expression);
1138
- return n;
1139
- }
1140
- visitJSXSpreadChild(n) {
1141
- n.expression = this.visitExpression(n.expression);
1142
- return n;
1143
- }
1144
- visitJSXOpeningFragment(n) {
1145
- return n;
1146
- }
1147
- visitJSXEmptyExpression(n) {
1148
- return n;
1149
- }
1150
- visitJSXElement(n) {
1151
- n.opening = this.visitJSXOpeningElement(n.opening);
1152
- n.children = this.visitJSXElementChildren(n.children);
1153
- n.closing = this.visitJSXClosingElement(n.closing);
1154
- return n;
1155
- }
1156
- visitJSXClosingElement(n) {
1157
- if (n) {
1158
- n.name = this.visitJSXElementName(n.name);
1159
- }
1160
- return n;
1161
- }
1162
- visitJSXElementName(n) {
1163
- switch (n.type) {
1164
- case 'Identifier':
1165
- return this.visitIdentifierReference(n);
1166
- case 'JSXMemberExpression':
1167
- return this.visitJSXMemberExpression(n);
1168
- case 'JSXNamespacedName':
1169
- return this.visitJSXNamespacedName(n);
1170
- }
1171
- }
1172
- visitJSXOpeningElement(n) {
1173
- n.name = this.visitJSXElementName(n.name);
1174
- n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
1175
- n.attributes = this.visitJSXAttributeOrSpreads(n.attributes);
1176
- return n;
1177
- }
1178
- visitJSXAttributes(attrs) {
1179
- if (attrs)
1180
- return attrs.map(this.visitJSXAttributeOrSpread.bind(this));
1181
- }
1182
- visitJSXAttributeOrSpread(n) {
1183
- switch (n.type) {
1184
- case 'JSXAttribute':
1185
- return this.visitJSXAttribute(n);
1186
- case 'SpreadElement':
1187
- return this.visitSpreadElement(n);
1188
- }
1189
- }
1190
- visitJSXAttributeOrSpreads(nodes) {
1191
- return nodes.map(this.visitJSXAttributeOrSpread.bind(this));
1192
- }
1193
- visitJSXAttribute(n) {
1194
- n.name = this.visitJSXAttributeName(n.name);
1195
- n.value = this.visitJSXAttributeValue(n.value);
1196
- return n;
1197
- }
1198
- visitJSXAttributeValue(n) {
1199
- if (!n)
1200
- return n;
1201
- switch (n.type) {
1202
- case 'BooleanLiteral':
1203
- return this.visitBooleanLiteral(n);
1204
- case 'NullLiteral':
1205
- return this.visitNullLiteral(n);
1206
- case 'NumericLiteral':
1207
- return this.visitNumericLiteral(n);
1208
- case 'JSXText':
1209
- return this.visitJSXText(n);
1210
- case 'StringLiteral':
1211
- return this.visitStringLiteral(n);
1212
- case 'JSXElement':
1213
- return this.visitJSXElement(n);
1214
- case 'JSXExpressionContainer':
1215
- return this.visitJSXExpressionContainer(n);
1216
- case 'JSXFragment':
1217
- return this.visitJSXFragment(n);
1218
- }
1219
- return n;
1220
- }
1221
- visitJSXAttributeName(n) {
1222
- switch (n.type) {
1223
- case 'Identifier':
1224
- return this.visitIdentifierReference(n);
1225
- case 'JSXNamespacedName':
1226
- return this.visitJSXNamespacedName(n);
1227
- }
1228
- }
1229
- visitConditionalExpression(n) {
1230
- n.test = this.visitExpression(n.test);
1231
- n.consequent = this.visitExpression(n.consequent);
1232
- n.alternate = this.visitExpression(n.alternate);
1233
- return n;
1234
- }
1235
- visitCallExpression(n) {
1236
- n.callee = this.visitCallee(n.callee);
1237
- n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments);
1238
- if (n.arguments) {
1239
- n.arguments = this.visitArguments(n.arguments);
1240
- }
1241
- return n;
1242
- }
1243
- visitBooleanLiteral(n) {
1244
- return n;
1245
- }
1246
- visitBinaryExpression(n) {
1247
- n.left = this.visitExpression(n.left);
1248
- n.right = this.visitExpression(n.right);
1249
- return n;
1250
- }
1251
- visitAwaitExpression(n) {
1252
- n.argument = this.visitExpression(n.argument);
1253
- return n;
1254
- }
1255
- visitTsTypeParameterDeclaration(n) {
1256
- if (n) {
1257
- n.parameters = this.visitTsTypeParameters(n.parameters);
1258
- }
1259
- return n;
1260
- }
1261
- visitTsTypeParameters(nodes) {
1262
- return nodes.map(this.visitTsTypeParameter.bind(this));
1263
- }
1264
- visitTsTypeParameter(n) {
1265
- if (n.constraint) {
1266
- n.constraint = this.visitTsType(n.constraint);
1267
- }
1268
- if (n.default) {
1269
- n.default = this.visitTsType(n.default);
1270
- }
1271
- n.name = this.visitIdentifierReference(n.name);
1272
- return n;
1273
- }
1274
- visitTsTypeAnnotation(a) {
1275
- if (a) {
1276
- a.typeAnnotation = this.visitTsType(a.typeAnnotation);
1277
- }
1278
- return a;
1279
- }
1280
- visitTsType(n) {
1281
- return n;
1282
- throw new Error('Method visitTsType not implemented.');
1283
- }
1284
- visitPatterns(nodes) {
1285
- return nodes.map(this.visitPattern.bind(this));
1286
- }
1287
- visitImportDeclaration(n) {
1288
- n.source = this.visitStringLiteral(n.source);
1289
- n.specifiers = this.visitImportSpecifiers(n.specifiers || []);
1290
- return n;
1291
- }
1292
- visitImportSpecifiers(nodes) {
1293
- return nodes.map(this.visitImportSpecifier.bind(this));
1294
- }
1295
- visitImportSpecifier(node) {
1296
- switch (node.type) {
1297
- case 'ImportDefaultSpecifier':
1298
- return this.visitImportDefaultSpecifier(node);
1299
- case 'ImportNamespaceSpecifier':
1300
- return this.visitImportNamespaceSpecifier(node);
1301
- case 'ImportSpecifier':
1302
- return this.visitNamedImportSpecifier(node);
1303
- }
1304
- }
1305
- visitNamedImportSpecifier(node) {
1306
- node.local = this.visitBindingIdentifier(node.local);
1307
- if (node.imported) {
1308
- node.imported = this.visitModuleExportName(node.imported);
1309
- }
1310
- return node;
1311
- }
1312
- visitImportNamespaceSpecifier(node) {
1313
- node.local = this.visitBindingIdentifier(node.local);
1314
- return node;
1315
- }
1316
- visitImportDefaultSpecifier(node) {
1317
- node.local = this.visitBindingIdentifier(node.local);
1318
- return node;
1319
- }
1320
- visitBindingIdentifier(i) {
1321
- if (i.typeAnnotation) {
1322
- i.typeAnnotation = this.visitTsTypeAnnotation(i.typeAnnotation);
1323
- }
1324
- return this.visitIdentifier(i);
1325
- }
1326
- visitIdentifierReference(i) {
1327
- return this.visitIdentifier(i);
1328
- }
1329
- visitLabelIdentifier(label) {
1330
- return this.visitIdentifier(label);
1331
- }
1332
- visitIdentifier(n) {
1333
- return n;
1334
- }
1335
- visitStringLiteral(n) {
1336
- return n;
1337
- }
1338
- visitNumericLiteral(n) {
1339
- return n;
1340
- }
1341
- visitBigIntLiteral(n) {
1342
- return n;
1343
- }
1344
- visitPattern(n) {
1345
- switch (n.type) {
1346
- case 'Identifier':
1347
- return this.visitBindingIdentifier(n);
1348
- case 'ArrayPattern':
1349
- return this.visitArrayPattern(n);
1350
- case 'ObjectPattern':
1351
- return this.visitObjectPattern(n);
1352
- case 'AssignmentPattern':
1353
- return this.visitAssignmentPattern(n);
1354
- case 'RestElement':
1355
- return this.visitRestElement(n);
1356
- default:
1357
- return this.visitExpression(n);
1358
- }
1359
- }
1360
- visitRestElement(n) {
1361
- n.argument = this.visitPattern(n.argument);
1362
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1363
- return n;
1364
- }
1365
- visitAssignmentPattern(n) {
1366
- n.left = this.visitPattern(n.left);
1367
- n.right = this.visitExpression(n.right);
1368
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1369
- return n;
1370
- }
1371
- visitObjectPattern(n) {
1372
- n.properties = this.visitObjectPatternProperties(n.properties || []);
1373
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1374
- return n;
1375
- }
1376
- visitObjectPatternProperties(nodes) {
1377
- return nodes.map(this.visitObjectPatternProperty.bind(this));
1378
- }
1379
- visitObjectPatternProperty(n) {
1380
- switch (n.type) {
1381
- case 'AssignmentPatternProperty':
1382
- return this.visitAssignmentPatternProperty(n);
1383
- case 'KeyValuePatternProperty':
1384
- return this.visitKeyValuePatternProperty(n);
1385
- case 'RestElement':
1386
- return this.visitRestElement(n);
1387
- }
1388
- }
1389
- visitKeyValuePatternProperty(n) {
1390
- n.key = this.visitPropertyName(n.key);
1391
- n.value = this.visitPattern(n.value);
1392
- return n;
1393
- }
1394
- visitAssignmentPatternProperty(n) {
1395
- n.key = this.visitBindingIdentifier(n.key);
1396
- n.value = this.visitOptionalExpression(n.value);
1397
- return n;
1398
- }
1399
- visitArrayPattern(n) {
1400
- n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
1401
- n.elements = this.visitArrayPatternElements(n.elements);
1402
- return n;
1403
- }
1404
- visitArrayPatternElements(nodes) {
1405
- return nodes.map(this.visitArrayPatternElement.bind(this));
1406
- }
1407
- visitArrayPatternElement(n) {
1408
- if (n) {
1409
- n = this.visitPattern(n);
1410
- }
1411
- return n;
1412
- }
1413
- }
1414
- exports.Visitor = Visitor;