yuku-ast 0.0.3

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.
package/dist/index.mjs ADDED
@@ -0,0 +1,2306 @@
1
+ //#region src/aliases.ts
2
+ /**
3
+ * Node types grouped under a shared alias. A visitor registered under an alias
4
+ * name runs for every member type. Membership is by node `type`.
5
+ */
6
+ const ALIAS_GROUPS = {
7
+ Expression: [
8
+ "Identifier",
9
+ "Literal",
10
+ "ThisExpression",
11
+ "Super",
12
+ "ArrayExpression",
13
+ "ObjectExpression",
14
+ "FunctionExpression",
15
+ "ArrowFunctionExpression",
16
+ "ClassExpression",
17
+ "TaggedTemplateExpression",
18
+ "TemplateLiteral",
19
+ "MemberExpression",
20
+ "CallExpression",
21
+ "NewExpression",
22
+ "ChainExpression",
23
+ "SequenceExpression",
24
+ "ParenthesizedExpression",
25
+ "BinaryExpression",
26
+ "LogicalExpression",
27
+ "ConditionalExpression",
28
+ "UnaryExpression",
29
+ "UpdateExpression",
30
+ "AssignmentExpression",
31
+ "YieldExpression",
32
+ "AwaitExpression",
33
+ "ImportExpression",
34
+ "MetaProperty",
35
+ "TSAsExpression",
36
+ "TSSatisfiesExpression",
37
+ "TSTypeAssertion",
38
+ "TSNonNullExpression",
39
+ "TSInstantiationExpression",
40
+ "JSXElement",
41
+ "JSXFragment"
42
+ ],
43
+ Statement: [
44
+ "ExpressionStatement",
45
+ "BlockStatement",
46
+ "EmptyStatement",
47
+ "DebuggerStatement",
48
+ "ReturnStatement",
49
+ "LabeledStatement",
50
+ "BreakStatement",
51
+ "ContinueStatement",
52
+ "IfStatement",
53
+ "SwitchStatement",
54
+ "ThrowStatement",
55
+ "TryStatement",
56
+ "WhileStatement",
57
+ "DoWhileStatement",
58
+ "ForStatement",
59
+ "ForInStatement",
60
+ "ForOfStatement",
61
+ "WithStatement",
62
+ "FunctionDeclaration",
63
+ "ClassDeclaration",
64
+ "VariableDeclaration",
65
+ "TSDeclareFunction",
66
+ "TSTypeAliasDeclaration",
67
+ "TSInterfaceDeclaration",
68
+ "TSEnumDeclaration",
69
+ "TSModuleDeclaration",
70
+ "TSImportEqualsDeclaration"
71
+ ],
72
+ Declaration: [
73
+ "FunctionDeclaration",
74
+ "ClassDeclaration",
75
+ "VariableDeclaration",
76
+ "TSDeclareFunction",
77
+ "TSTypeAliasDeclaration",
78
+ "TSInterfaceDeclaration",
79
+ "TSEnumDeclaration",
80
+ "TSModuleDeclaration",
81
+ "TSImportEqualsDeclaration"
82
+ ],
83
+ ModuleDeclaration: [
84
+ "ImportDeclaration",
85
+ "ExportNamedDeclaration",
86
+ "ExportDefaultDeclaration",
87
+ "ExportAllDeclaration",
88
+ "TSExportAssignment",
89
+ "TSNamespaceExportDeclaration"
90
+ ],
91
+ Function: [
92
+ "FunctionDeclaration",
93
+ "FunctionExpression",
94
+ "ArrowFunctionExpression",
95
+ "TSDeclareFunction",
96
+ "TSEmptyBodyFunctionExpression"
97
+ ],
98
+ Class: ["ClassDeclaration", "ClassExpression"],
99
+ Method: ["MethodDefinition", "TSAbstractMethodDefinition"],
100
+ Loop: [
101
+ "ForStatement",
102
+ "ForInStatement",
103
+ "ForOfStatement",
104
+ "WhileStatement",
105
+ "DoWhileStatement"
106
+ ],
107
+ Pattern: [
108
+ "Identifier",
109
+ "ArrayPattern",
110
+ "ObjectPattern",
111
+ "AssignmentPattern",
112
+ "RestElement"
113
+ ],
114
+ JSX: [
115
+ "JSXElement",
116
+ "JSXOpeningElement",
117
+ "JSXClosingElement",
118
+ "JSXFragment",
119
+ "JSXOpeningFragment",
120
+ "JSXClosingFragment",
121
+ "JSXIdentifier",
122
+ "JSXNamespacedName",
123
+ "JSXMemberExpression",
124
+ "JSXAttribute",
125
+ "JSXSpreadAttribute",
126
+ "JSXExpressionContainer",
127
+ "JSXEmptyExpression",
128
+ "JSXText",
129
+ "JSXSpreadChild"
130
+ ],
131
+ TSType: [
132
+ "TSAnyKeyword",
133
+ "TSUnknownKeyword",
134
+ "TSNeverKeyword",
135
+ "TSVoidKeyword",
136
+ "TSNullKeyword",
137
+ "TSUndefinedKeyword",
138
+ "TSStringKeyword",
139
+ "TSNumberKeyword",
140
+ "TSBigIntKeyword",
141
+ "TSBooleanKeyword",
142
+ "TSSymbolKeyword",
143
+ "TSObjectKeyword",
144
+ "TSIntrinsicKeyword",
145
+ "TSThisType",
146
+ "TSTypeReference",
147
+ "TSTypeQuery",
148
+ "TSImportType",
149
+ "TSLiteralType",
150
+ "TSTemplateLiteralType",
151
+ "TSArrayType",
152
+ "TSIndexedAccessType",
153
+ "TSTupleType",
154
+ "TSNamedTupleMember",
155
+ "TSJSDocNullableType",
156
+ "TSJSDocNonNullableType",
157
+ "TSJSDocUnknownType",
158
+ "TSUnionType",
159
+ "TSIntersectionType",
160
+ "TSConditionalType",
161
+ "TSInferType",
162
+ "TSTypeOperator",
163
+ "TSParenthesizedType",
164
+ "TSFunctionType",
165
+ "TSConstructorType",
166
+ "TSTypePredicate",
167
+ "TSTypeLiteral",
168
+ "TSMappedType"
169
+ ]
170
+ };
171
+ //#endregion
172
+ //#region src/visitor-keys.ts
173
+ /**
174
+ * Child fields of each node type, in traversal order. Names are validated
175
+ * against the AST types, so a renamed, removed, or added field fails to compile.
176
+ */
177
+ const VISITOR_KEYS = {
178
+ Program: ["hashbang", "body"],
179
+ Hashbang: [],
180
+ Identifier: ["decorators", "typeAnnotation"],
181
+ PrivateIdentifier: [],
182
+ Literal: [],
183
+ TemplateElement: [],
184
+ Super: [],
185
+ ThisExpression: [],
186
+ ArrayPattern: [
187
+ "decorators",
188
+ "elements",
189
+ "typeAnnotation"
190
+ ],
191
+ ObjectPattern: [
192
+ "decorators",
193
+ "properties",
194
+ "typeAnnotation"
195
+ ],
196
+ AssignmentPattern: [
197
+ "decorators",
198
+ "left",
199
+ "right",
200
+ "typeAnnotation"
201
+ ],
202
+ RestElement: [
203
+ "decorators",
204
+ "argument",
205
+ "typeAnnotation"
206
+ ],
207
+ Property: ["key", "value"],
208
+ SequenceExpression: ["expressions"],
209
+ ParenthesizedExpression: ["expression"],
210
+ BinaryExpression: ["left", "right"],
211
+ LogicalExpression: ["left", "right"],
212
+ ConditionalExpression: [
213
+ "test",
214
+ "consequent",
215
+ "alternate"
216
+ ],
217
+ UnaryExpression: ["argument"],
218
+ UpdateExpression: ["argument"],
219
+ AssignmentExpression: ["left", "right"],
220
+ YieldExpression: ["argument"],
221
+ AwaitExpression: ["argument"],
222
+ ArrayExpression: ["elements"],
223
+ ObjectExpression: ["properties"],
224
+ SpreadElement: ["argument"],
225
+ MemberExpression: ["object", "property"],
226
+ CallExpression: [
227
+ "callee",
228
+ "typeArguments",
229
+ "arguments"
230
+ ],
231
+ ChainExpression: ["expression"],
232
+ TaggedTemplateExpression: [
233
+ "tag",
234
+ "typeArguments",
235
+ "quasi"
236
+ ],
237
+ NewExpression: [
238
+ "callee",
239
+ "typeArguments",
240
+ "arguments"
241
+ ],
242
+ MetaProperty: ["meta", "property"],
243
+ ImportExpression: ["source", "options"],
244
+ TemplateLiteral: ["quasis", "expressions"],
245
+ ExpressionStatement: ["expression"],
246
+ BlockStatement: ["body"],
247
+ IfStatement: [
248
+ "test",
249
+ "consequent",
250
+ "alternate"
251
+ ],
252
+ SwitchStatement: ["discriminant", "cases"],
253
+ SwitchCase: ["test", "consequent"],
254
+ ForStatement: [
255
+ "init",
256
+ "test",
257
+ "update",
258
+ "body"
259
+ ],
260
+ ForInStatement: [
261
+ "left",
262
+ "right",
263
+ "body"
264
+ ],
265
+ ForOfStatement: [
266
+ "left",
267
+ "right",
268
+ "body"
269
+ ],
270
+ WhileStatement: ["test", "body"],
271
+ DoWhileStatement: ["body", "test"],
272
+ BreakStatement: ["label"],
273
+ ContinueStatement: ["label"],
274
+ LabeledStatement: ["label", "body"],
275
+ WithStatement: ["object", "body"],
276
+ ReturnStatement: ["argument"],
277
+ ThrowStatement: ["argument"],
278
+ TryStatement: [
279
+ "block",
280
+ "handler",
281
+ "finalizer"
282
+ ],
283
+ CatchClause: ["param", "body"],
284
+ DebuggerStatement: [],
285
+ EmptyStatement: [],
286
+ VariableDeclaration: ["declarations"],
287
+ VariableDeclarator: ["id", "init"],
288
+ FunctionDeclaration: [
289
+ "id",
290
+ "typeParameters",
291
+ "params",
292
+ "returnType",
293
+ "body"
294
+ ],
295
+ FunctionExpression: [
296
+ "id",
297
+ "typeParameters",
298
+ "params",
299
+ "returnType",
300
+ "body"
301
+ ],
302
+ TSDeclareFunction: [
303
+ "id",
304
+ "typeParameters",
305
+ "params",
306
+ "returnType"
307
+ ],
308
+ TSEmptyBodyFunctionExpression: [
309
+ "id",
310
+ "typeParameters",
311
+ "params",
312
+ "returnType"
313
+ ],
314
+ ArrowFunctionExpression: [
315
+ "typeParameters",
316
+ "params",
317
+ "returnType",
318
+ "body"
319
+ ],
320
+ ClassDeclaration: [
321
+ "decorators",
322
+ "id",
323
+ "typeParameters",
324
+ "superClass",
325
+ "superTypeArguments",
326
+ "implements",
327
+ "body"
328
+ ],
329
+ ClassExpression: [
330
+ "decorators",
331
+ "id",
332
+ "typeParameters",
333
+ "superClass",
334
+ "superTypeArguments",
335
+ "implements",
336
+ "body"
337
+ ],
338
+ ClassBody: ["body"],
339
+ MethodDefinition: [
340
+ "decorators",
341
+ "key",
342
+ "value"
343
+ ],
344
+ TSAbstractMethodDefinition: [
345
+ "decorators",
346
+ "key",
347
+ "value"
348
+ ],
349
+ PropertyDefinition: [
350
+ "decorators",
351
+ "key",
352
+ "typeAnnotation",
353
+ "value"
354
+ ],
355
+ TSAbstractPropertyDefinition: [
356
+ "decorators",
357
+ "key",
358
+ "typeAnnotation",
359
+ "value"
360
+ ],
361
+ AccessorProperty: [
362
+ "decorators",
363
+ "key",
364
+ "typeAnnotation",
365
+ "value"
366
+ ],
367
+ TSAbstractAccessorProperty: [
368
+ "decorators",
369
+ "key",
370
+ "typeAnnotation",
371
+ "value"
372
+ ],
373
+ StaticBlock: ["body"],
374
+ Decorator: ["expression"],
375
+ ImportDeclaration: [
376
+ "specifiers",
377
+ "source",
378
+ "attributes"
379
+ ],
380
+ ImportSpecifier: ["imported", "local"],
381
+ ImportDefaultSpecifier: ["local"],
382
+ ImportNamespaceSpecifier: ["local"],
383
+ ImportAttribute: ["key", "value"],
384
+ ExportNamedDeclaration: [
385
+ "declaration",
386
+ "specifiers",
387
+ "source",
388
+ "attributes"
389
+ ],
390
+ ExportDefaultDeclaration: ["declaration"],
391
+ ExportAllDeclaration: [
392
+ "exported",
393
+ "source",
394
+ "attributes"
395
+ ],
396
+ ExportSpecifier: ["local", "exported"],
397
+ JSXElement: [
398
+ "openingElement",
399
+ "children",
400
+ "closingElement"
401
+ ],
402
+ JSXOpeningElement: [
403
+ "name",
404
+ "typeArguments",
405
+ "attributes"
406
+ ],
407
+ JSXClosingElement: ["name"],
408
+ JSXFragment: [
409
+ "openingFragment",
410
+ "children",
411
+ "closingFragment"
412
+ ],
413
+ JSXOpeningFragment: [],
414
+ JSXClosingFragment: [],
415
+ JSXIdentifier: [],
416
+ JSXNamespacedName: ["namespace", "name"],
417
+ JSXMemberExpression: ["object", "property"],
418
+ JSXAttribute: ["name", "value"],
419
+ JSXSpreadAttribute: ["argument"],
420
+ JSXExpressionContainer: ["expression"],
421
+ JSXEmptyExpression: [],
422
+ JSXText: [],
423
+ JSXSpreadChild: ["expression"],
424
+ TSTypeAnnotation: ["typeAnnotation"],
425
+ TSAnyKeyword: [],
426
+ TSUnknownKeyword: [],
427
+ TSNeverKeyword: [],
428
+ TSVoidKeyword: [],
429
+ TSNullKeyword: [],
430
+ TSUndefinedKeyword: [],
431
+ TSStringKeyword: [],
432
+ TSNumberKeyword: [],
433
+ TSBigIntKeyword: [],
434
+ TSBooleanKeyword: [],
435
+ TSSymbolKeyword: [],
436
+ TSObjectKeyword: [],
437
+ TSIntrinsicKeyword: [],
438
+ TSThisType: [],
439
+ TSTypeReference: ["typeName", "typeArguments"],
440
+ TSQualifiedName: ["left", "right"],
441
+ TSTypeQuery: ["exprName", "typeArguments"],
442
+ TSImportType: [
443
+ "source",
444
+ "options",
445
+ "qualifier",
446
+ "typeArguments"
447
+ ],
448
+ TSTypeParameter: [
449
+ "name",
450
+ "constraint",
451
+ "default"
452
+ ],
453
+ TSTypeParameterDeclaration: ["params"],
454
+ TSTypeParameterInstantiation: ["params"],
455
+ TSLiteralType: ["literal"],
456
+ TSTemplateLiteralType: ["quasis", "types"],
457
+ TSArrayType: ["elementType"],
458
+ TSIndexedAccessType: ["objectType", "indexType"],
459
+ TSTupleType: ["elementTypes"],
460
+ TSNamedTupleMember: ["label", "elementType"],
461
+ TSOptionalType: ["typeAnnotation"],
462
+ TSRestType: ["typeAnnotation"],
463
+ TSJSDocNullableType: ["typeAnnotation"],
464
+ TSJSDocNonNullableType: ["typeAnnotation"],
465
+ TSJSDocUnknownType: [],
466
+ TSUnionType: ["types"],
467
+ TSIntersectionType: ["types"],
468
+ TSConditionalType: [
469
+ "checkType",
470
+ "extendsType",
471
+ "trueType",
472
+ "falseType"
473
+ ],
474
+ TSInferType: ["typeParameter"],
475
+ TSTypeOperator: ["typeAnnotation"],
476
+ TSParenthesizedType: ["typeAnnotation"],
477
+ TSFunctionType: [
478
+ "typeParameters",
479
+ "params",
480
+ "returnType"
481
+ ],
482
+ TSConstructorType: [
483
+ "typeParameters",
484
+ "params",
485
+ "returnType"
486
+ ],
487
+ TSTypePredicate: ["parameterName", "typeAnnotation"],
488
+ TSTypeLiteral: ["members"],
489
+ TSMappedType: [
490
+ "key",
491
+ "constraint",
492
+ "nameType",
493
+ "typeAnnotation"
494
+ ],
495
+ TSPropertySignature: ["key", "typeAnnotation"],
496
+ TSMethodSignature: [
497
+ "key",
498
+ "typeParameters",
499
+ "params",
500
+ "returnType"
501
+ ],
502
+ TSCallSignatureDeclaration: [
503
+ "typeParameters",
504
+ "params",
505
+ "returnType"
506
+ ],
507
+ TSConstructSignatureDeclaration: [
508
+ "typeParameters",
509
+ "params",
510
+ "returnType"
511
+ ],
512
+ TSIndexSignature: ["parameters", "typeAnnotation"],
513
+ TSTypeAliasDeclaration: [
514
+ "id",
515
+ "typeParameters",
516
+ "typeAnnotation"
517
+ ],
518
+ TSInterfaceDeclaration: [
519
+ "id",
520
+ "typeParameters",
521
+ "extends",
522
+ "body"
523
+ ],
524
+ TSInterfaceBody: ["body"],
525
+ TSInterfaceHeritage: ["expression", "typeArguments"],
526
+ TSClassImplements: ["expression", "typeArguments"],
527
+ TSEnumDeclaration: ["id", "body"],
528
+ TSEnumBody: ["members"],
529
+ TSEnumMember: ["id", "initializer"],
530
+ TSModuleDeclaration: ["id", "body"],
531
+ TSModuleBlock: ["body"],
532
+ TSParameterProperty: ["decorators", "parameter"],
533
+ TSAsExpression: ["expression", "typeAnnotation"],
534
+ TSSatisfiesExpression: ["expression", "typeAnnotation"],
535
+ TSTypeAssertion: ["typeAnnotation", "expression"],
536
+ TSNonNullExpression: ["expression"],
537
+ TSInstantiationExpression: ["expression", "typeArguments"],
538
+ TSExportAssignment: ["expression"],
539
+ TSNamespaceExportDeclaration: ["id"],
540
+ TSImportEqualsDeclaration: ["id", "moduleReference"],
541
+ TSExternalModuleReference: ["expression"]
542
+ };
543
+ //#endregion
544
+ //#region src/predicates.ts
545
+ function aliasGuard(name) {
546
+ const set = new Set(ALIAS_GROUPS[name]);
547
+ return (node) => node != null && set.has(node.type);
548
+ }
549
+ const is = {
550
+ ...Object.fromEntries(Object.keys(VISITOR_KEYS).map((type) => [type, (node) => node != null && node.type === type])),
551
+ Expression: aliasGuard("Expression"),
552
+ Statement: aliasGuard("Statement"),
553
+ Declaration: aliasGuard("Declaration"),
554
+ ModuleDeclaration: aliasGuard("ModuleDeclaration"),
555
+ Function: aliasGuard("Function"),
556
+ Class: aliasGuard("Class"),
557
+ Method: aliasGuard("Method"),
558
+ Loop: aliasGuard("Loop"),
559
+ Pattern: aliasGuard("Pattern"),
560
+ JSX: aliasGuard("JSX"),
561
+ TSType: aliasGuard("TSType"),
562
+ IdentifierReference: (node) => node?.type === "Identifier" && node.kind === "reference",
563
+ BindingIdentifier: (node) => node?.type === "Identifier" && node.kind === "binding",
564
+ LabelIdentifier: (node) => node?.type === "Identifier" && node.kind === "label",
565
+ IdentifierName: (node) => node?.type === "Identifier" && node.kind === "name",
566
+ StringLiteral: (node) => node?.type === "Literal" && typeof node.value === "string",
567
+ NumericLiteral: (node) => node?.type === "Literal" && typeof node.value === "number",
568
+ BooleanLiteral: (node) => node?.type === "Literal" && typeof node.value === "boolean",
569
+ NullLiteral: (node) => node?.type === "Literal" && node.raw === "null",
570
+ BigIntLiteral: (node) => node?.type === "Literal" && "bigint" in node,
571
+ RegExpLiteral: (node) => node?.type === "Literal" && "regex" in node,
572
+ ComputedMemberExpression: (node) => node?.type === "MemberExpression" && node.computed,
573
+ StaticMemberExpression: (node) => node?.type === "MemberExpression" && !node.computed && node.property.type === "Identifier",
574
+ PrivateFieldExpression: (node) => node?.type === "MemberExpression" && node.property.type === "PrivateIdentifier",
575
+ Directive: (node) => node?.type === "ExpressionStatement" && node.directive != null
576
+ };
577
+ //#endregion
578
+ //#region src/builders.ts
579
+ const span = {
580
+ start: 0,
581
+ end: 0
582
+ };
583
+ const isComputedKey = (key) => key.type !== "Identifier" && key.type !== "PrivateIdentifier";
584
+ const b = {
585
+ identifier(name, kind = "reference", opts = {}) {
586
+ return {
587
+ type: "Identifier",
588
+ name,
589
+ kind,
590
+ ...opts,
591
+ ...span
592
+ };
593
+ },
594
+ privateIdentifier(name) {
595
+ return {
596
+ type: "PrivateIdentifier",
597
+ name,
598
+ ...span
599
+ };
600
+ },
601
+ stringLiteral(value) {
602
+ return {
603
+ type: "Literal",
604
+ value,
605
+ raw: JSON.stringify(value),
606
+ ...span
607
+ };
608
+ },
609
+ numericLiteral(value) {
610
+ return {
611
+ type: "Literal",
612
+ value,
613
+ raw: String(value),
614
+ ...span
615
+ };
616
+ },
617
+ booleanLiteral(value) {
618
+ return {
619
+ type: "Literal",
620
+ value,
621
+ raw: String(value),
622
+ ...span
623
+ };
624
+ },
625
+ nullLiteral() {
626
+ return {
627
+ type: "Literal",
628
+ value: null,
629
+ raw: "null",
630
+ ...span
631
+ };
632
+ },
633
+ bigIntLiteral(value) {
634
+ return {
635
+ type: "Literal",
636
+ value,
637
+ raw: `${value}n`,
638
+ bigint: String(value),
639
+ ...span
640
+ };
641
+ },
642
+ regExpLiteral(pattern, flags = "") {
643
+ let value = null;
644
+ try {
645
+ value = new RegExp(pattern, flags);
646
+ } catch {}
647
+ return {
648
+ type: "Literal",
649
+ value,
650
+ raw: `/${pattern}/${flags}`,
651
+ regex: {
652
+ pattern,
653
+ flags
654
+ },
655
+ ...span
656
+ };
657
+ },
658
+ templateLiteral(quasis, expressions) {
659
+ return {
660
+ type: "TemplateLiteral",
661
+ quasis,
662
+ expressions,
663
+ ...span
664
+ };
665
+ },
666
+ templateElement(cooked, tail = false) {
667
+ return {
668
+ type: "TemplateElement",
669
+ value: {
670
+ raw: cooked,
671
+ cooked
672
+ },
673
+ tail,
674
+ ...span
675
+ };
676
+ },
677
+ thisExpression() {
678
+ return {
679
+ type: "ThisExpression",
680
+ ...span
681
+ };
682
+ },
683
+ super() {
684
+ return {
685
+ type: "Super",
686
+ ...span
687
+ };
688
+ },
689
+ arrayPattern(elements) {
690
+ return {
691
+ type: "ArrayPattern",
692
+ elements,
693
+ ...span
694
+ };
695
+ },
696
+ objectPattern(properties) {
697
+ return {
698
+ type: "ObjectPattern",
699
+ properties,
700
+ ...span
701
+ };
702
+ },
703
+ assignmentPattern(left, right) {
704
+ return {
705
+ type: "AssignmentPattern",
706
+ left,
707
+ right,
708
+ ...span
709
+ };
710
+ },
711
+ restElement(argument) {
712
+ return {
713
+ type: "RestElement",
714
+ argument,
715
+ ...span
716
+ };
717
+ },
718
+ /** A member of an `ObjectExpression`. For an `ObjectPattern` member, use {@link bindingProperty}. */
719
+ objectProperty(key, value, opts = {}) {
720
+ return {
721
+ type: "Property",
722
+ kind: opts.kind ?? "init",
723
+ key,
724
+ value,
725
+ method: opts.method ?? false,
726
+ shorthand: opts.shorthand ?? false,
727
+ computed: opts.computed ?? isComputedKey(key),
728
+ ...span
729
+ };
730
+ },
731
+ /** A member of an `ObjectPattern`, whose value is a binding target. For an `ObjectExpression` member, use {@link objectProperty}. */
732
+ bindingProperty(key, value, opts = {}) {
733
+ return {
734
+ type: "Property",
735
+ kind: "init",
736
+ key,
737
+ value,
738
+ method: false,
739
+ shorthand: opts.shorthand ?? false,
740
+ computed: opts.computed ?? isComputedKey(key),
741
+ ...span
742
+ };
743
+ },
744
+ arrayExpression(elements = []) {
745
+ return {
746
+ type: "ArrayExpression",
747
+ elements,
748
+ ...span
749
+ };
750
+ },
751
+ objectExpression(properties = []) {
752
+ return {
753
+ type: "ObjectExpression",
754
+ properties,
755
+ ...span
756
+ };
757
+ },
758
+ spreadElement(argument) {
759
+ return {
760
+ type: "SpreadElement",
761
+ argument,
762
+ ...span
763
+ };
764
+ },
765
+ sequenceExpression(expressions) {
766
+ return {
767
+ type: "SequenceExpression",
768
+ expressions,
769
+ ...span
770
+ };
771
+ },
772
+ parenthesizedExpression(expression) {
773
+ return {
774
+ type: "ParenthesizedExpression",
775
+ expression,
776
+ ...span
777
+ };
778
+ },
779
+ unaryExpression(operator, argument) {
780
+ return {
781
+ type: "UnaryExpression",
782
+ operator,
783
+ prefix: true,
784
+ argument,
785
+ ...span
786
+ };
787
+ },
788
+ updateExpression(operator, argument, prefix = false) {
789
+ return {
790
+ type: "UpdateExpression",
791
+ operator,
792
+ argument,
793
+ prefix,
794
+ ...span
795
+ };
796
+ },
797
+ binaryExpression(operator, left, right) {
798
+ return {
799
+ type: "BinaryExpression",
800
+ operator,
801
+ left,
802
+ right,
803
+ ...span
804
+ };
805
+ },
806
+ logicalExpression(operator, left, right) {
807
+ return {
808
+ type: "LogicalExpression",
809
+ operator,
810
+ left,
811
+ right,
812
+ ...span
813
+ };
814
+ },
815
+ assignmentExpression(operator, left, right) {
816
+ return {
817
+ type: "AssignmentExpression",
818
+ operator,
819
+ left,
820
+ right,
821
+ ...span
822
+ };
823
+ },
824
+ conditionalExpression(test, consequent, alternate) {
825
+ return {
826
+ type: "ConditionalExpression",
827
+ test,
828
+ consequent,
829
+ alternate,
830
+ ...span
831
+ };
832
+ },
833
+ yieldExpression(argument = null, delegate = false) {
834
+ return {
835
+ type: "YieldExpression",
836
+ delegate,
837
+ argument,
838
+ ...span
839
+ };
840
+ },
841
+ awaitExpression(argument) {
842
+ return {
843
+ type: "AwaitExpression",
844
+ argument,
845
+ ...span
846
+ };
847
+ },
848
+ memberExpression(object, property, opts = {}) {
849
+ return {
850
+ type: "MemberExpression",
851
+ object,
852
+ property,
853
+ computed: opts.computed ?? isComputedKey(property),
854
+ optional: opts.optional ?? false,
855
+ ...span
856
+ };
857
+ },
858
+ callExpression(callee, args = [], opts = {}) {
859
+ return {
860
+ type: "CallExpression",
861
+ callee,
862
+ arguments: args,
863
+ optional: opts.optional ?? false,
864
+ ...opts,
865
+ ...span
866
+ };
867
+ },
868
+ newExpression(callee, args = [], opts = {}) {
869
+ return {
870
+ type: "NewExpression",
871
+ callee,
872
+ arguments: args,
873
+ ...opts,
874
+ ...span
875
+ };
876
+ },
877
+ chainExpression(expression) {
878
+ return {
879
+ type: "ChainExpression",
880
+ expression,
881
+ ...span
882
+ };
883
+ },
884
+ taggedTemplateExpression(tag, quasi, opts = {}) {
885
+ return {
886
+ type: "TaggedTemplateExpression",
887
+ tag,
888
+ quasi,
889
+ ...opts,
890
+ ...span
891
+ };
892
+ },
893
+ metaProperty(meta, property) {
894
+ return {
895
+ type: "MetaProperty",
896
+ meta: b.identifier(meta, "name"),
897
+ property: b.identifier(property, "name"),
898
+ ...span
899
+ };
900
+ },
901
+ importExpression(source, opts = {}) {
902
+ return {
903
+ type: "ImportExpression",
904
+ source,
905
+ options: opts.options ?? null,
906
+ phase: opts.phase ?? null,
907
+ ...span
908
+ };
909
+ },
910
+ arrowFunctionExpression(params, body, opts = {}) {
911
+ return {
912
+ type: "ArrowFunctionExpression",
913
+ id: null,
914
+ generator: false,
915
+ async: opts.async ?? false,
916
+ params,
917
+ body,
918
+ expression: body.type !== "BlockStatement",
919
+ ...opts,
920
+ ...span
921
+ };
922
+ },
923
+ functionExpression(params, body, opts = {}) {
924
+ return {
925
+ type: "FunctionExpression",
926
+ id: opts.id ?? null,
927
+ generator: opts.generator ?? false,
928
+ async: opts.async ?? false,
929
+ params,
930
+ body,
931
+ expression: false,
932
+ ...span
933
+ };
934
+ },
935
+ functionDeclaration(id, params, body, opts = {}) {
936
+ return {
937
+ type: "FunctionDeclaration",
938
+ id,
939
+ generator: opts.generator ?? false,
940
+ async: opts.async ?? false,
941
+ params,
942
+ body,
943
+ expression: false,
944
+ ...span
945
+ };
946
+ },
947
+ classDeclaration(id, body, opts = {}) {
948
+ return {
949
+ type: "ClassDeclaration",
950
+ decorators: opts.decorators ?? [],
951
+ id,
952
+ superClass: opts.superClass ?? null,
953
+ body,
954
+ ...opts,
955
+ ...span
956
+ };
957
+ },
958
+ classExpression(id, body, opts = {}) {
959
+ return {
960
+ type: "ClassExpression",
961
+ decorators: opts.decorators ?? [],
962
+ id,
963
+ superClass: opts.superClass ?? null,
964
+ body,
965
+ ...span
966
+ };
967
+ },
968
+ classBody(body = []) {
969
+ return {
970
+ type: "ClassBody",
971
+ body,
972
+ ...span
973
+ };
974
+ },
975
+ methodDefinition(key, value, opts = {}) {
976
+ return {
977
+ type: "MethodDefinition",
978
+ decorators: [],
979
+ key,
980
+ value,
981
+ kind: opts.kind ?? "method",
982
+ computed: opts.computed ?? isComputedKey(key),
983
+ static: opts.static ?? false,
984
+ ...span
985
+ };
986
+ },
987
+ propertyDefinition(key, value = null, opts = {}) {
988
+ return {
989
+ type: "PropertyDefinition",
990
+ decorators: opts.decorators ?? [],
991
+ key,
992
+ value,
993
+ computed: opts.computed ?? isComputedKey(key),
994
+ static: opts.static ?? false,
995
+ ...span
996
+ };
997
+ },
998
+ accessorProperty(key, value = null, opts = {}) {
999
+ return {
1000
+ type: "AccessorProperty",
1001
+ decorators: [],
1002
+ key,
1003
+ value,
1004
+ computed: opts.computed ?? isComputedKey(key),
1005
+ static: opts.static ?? false,
1006
+ ...span
1007
+ };
1008
+ },
1009
+ tsAbstractMethodDefinition(key, value, opts = {}) {
1010
+ return {
1011
+ type: "TSAbstractMethodDefinition",
1012
+ decorators: [],
1013
+ key,
1014
+ value,
1015
+ kind: opts.kind ?? "method",
1016
+ computed: opts.computed ?? isComputedKey(key),
1017
+ static: opts.static ?? false,
1018
+ ...span
1019
+ };
1020
+ },
1021
+ tsAbstractPropertyDefinition(key, value = null, opts = {}) {
1022
+ return {
1023
+ type: "TSAbstractPropertyDefinition",
1024
+ decorators: [],
1025
+ key,
1026
+ value,
1027
+ computed: opts.computed ?? isComputedKey(key),
1028
+ static: opts.static ?? false,
1029
+ ...span
1030
+ };
1031
+ },
1032
+ tsAbstractAccessorProperty(key, value = null, opts = {}) {
1033
+ return {
1034
+ type: "TSAbstractAccessorProperty",
1035
+ decorators: [],
1036
+ key,
1037
+ value,
1038
+ computed: opts.computed ?? isComputedKey(key),
1039
+ static: opts.static ?? false,
1040
+ ...span
1041
+ };
1042
+ },
1043
+ staticBlock(body = []) {
1044
+ return {
1045
+ type: "StaticBlock",
1046
+ body,
1047
+ ...span
1048
+ };
1049
+ },
1050
+ decorator(expression) {
1051
+ return {
1052
+ type: "Decorator",
1053
+ expression,
1054
+ ...span
1055
+ };
1056
+ },
1057
+ expressionStatement(expression) {
1058
+ return {
1059
+ type: "ExpressionStatement",
1060
+ expression,
1061
+ ...span
1062
+ };
1063
+ },
1064
+ directive(value) {
1065
+ return {
1066
+ type: "ExpressionStatement",
1067
+ expression: b.stringLiteral(value),
1068
+ directive: value,
1069
+ ...span
1070
+ };
1071
+ },
1072
+ blockStatement(body = []) {
1073
+ return {
1074
+ type: "BlockStatement",
1075
+ body,
1076
+ ...span
1077
+ };
1078
+ },
1079
+ emptyStatement() {
1080
+ return {
1081
+ type: "EmptyStatement",
1082
+ ...span
1083
+ };
1084
+ },
1085
+ debuggerStatement() {
1086
+ return {
1087
+ type: "DebuggerStatement",
1088
+ ...span
1089
+ };
1090
+ },
1091
+ returnStatement(argument = null) {
1092
+ return {
1093
+ type: "ReturnStatement",
1094
+ argument,
1095
+ ...span
1096
+ };
1097
+ },
1098
+ ifStatement(test, consequent, alternate = null) {
1099
+ return {
1100
+ type: "IfStatement",
1101
+ test,
1102
+ consequent,
1103
+ alternate,
1104
+ ...span
1105
+ };
1106
+ },
1107
+ switchStatement(discriminant, cases) {
1108
+ return {
1109
+ type: "SwitchStatement",
1110
+ discriminant,
1111
+ cases,
1112
+ ...span
1113
+ };
1114
+ },
1115
+ switchCase(test, consequent) {
1116
+ return {
1117
+ type: "SwitchCase",
1118
+ test,
1119
+ consequent,
1120
+ ...span
1121
+ };
1122
+ },
1123
+ throwStatement(argument) {
1124
+ return {
1125
+ type: "ThrowStatement",
1126
+ argument,
1127
+ ...span
1128
+ };
1129
+ },
1130
+ tryStatement(block, handler = null, finalizer = null) {
1131
+ return {
1132
+ type: "TryStatement",
1133
+ block,
1134
+ handler,
1135
+ finalizer,
1136
+ ...span
1137
+ };
1138
+ },
1139
+ catchClause(param, body) {
1140
+ return {
1141
+ type: "CatchClause",
1142
+ param,
1143
+ body,
1144
+ ...span
1145
+ };
1146
+ },
1147
+ whileStatement(test, body) {
1148
+ return {
1149
+ type: "WhileStatement",
1150
+ test,
1151
+ body,
1152
+ ...span
1153
+ };
1154
+ },
1155
+ doWhileStatement(body, test) {
1156
+ return {
1157
+ type: "DoWhileStatement",
1158
+ body,
1159
+ test,
1160
+ ...span
1161
+ };
1162
+ },
1163
+ forStatement(init, test, update, body) {
1164
+ return {
1165
+ type: "ForStatement",
1166
+ init,
1167
+ test,
1168
+ update,
1169
+ body,
1170
+ ...span
1171
+ };
1172
+ },
1173
+ forInStatement(left, right, body) {
1174
+ return {
1175
+ type: "ForInStatement",
1176
+ left,
1177
+ right,
1178
+ body,
1179
+ ...span
1180
+ };
1181
+ },
1182
+ forOfStatement(left, right, body, isAwait = false) {
1183
+ return {
1184
+ type: "ForOfStatement",
1185
+ left,
1186
+ right,
1187
+ body,
1188
+ await: isAwait,
1189
+ ...span
1190
+ };
1191
+ },
1192
+ labeledStatement(label, body) {
1193
+ return {
1194
+ type: "LabeledStatement",
1195
+ label,
1196
+ body,
1197
+ ...span
1198
+ };
1199
+ },
1200
+ breakStatement(label = null) {
1201
+ return {
1202
+ type: "BreakStatement",
1203
+ label,
1204
+ ...span
1205
+ };
1206
+ },
1207
+ continueStatement(label = null) {
1208
+ return {
1209
+ type: "ContinueStatement",
1210
+ label,
1211
+ ...span
1212
+ };
1213
+ },
1214
+ withStatement(object, body) {
1215
+ return {
1216
+ type: "WithStatement",
1217
+ object,
1218
+ body,
1219
+ ...span
1220
+ };
1221
+ },
1222
+ variableDeclaration(kind, declarations) {
1223
+ return {
1224
+ type: "VariableDeclaration",
1225
+ kind,
1226
+ declarations,
1227
+ ...span
1228
+ };
1229
+ },
1230
+ variableDeclarator(id, init = null) {
1231
+ return {
1232
+ type: "VariableDeclarator",
1233
+ id,
1234
+ init,
1235
+ ...span
1236
+ };
1237
+ },
1238
+ importDeclaration(specifiers, source, opts = {}) {
1239
+ return {
1240
+ type: "ImportDeclaration",
1241
+ specifiers,
1242
+ source,
1243
+ phase: opts.phase ?? null,
1244
+ attributes: opts.attributes ?? [],
1245
+ ...opts,
1246
+ ...span
1247
+ };
1248
+ },
1249
+ importSpecifier(imported, local) {
1250
+ return {
1251
+ type: "ImportSpecifier",
1252
+ imported,
1253
+ local,
1254
+ ...span
1255
+ };
1256
+ },
1257
+ importDefaultSpecifier(local) {
1258
+ return {
1259
+ type: "ImportDefaultSpecifier",
1260
+ local,
1261
+ ...span
1262
+ };
1263
+ },
1264
+ importNamespaceSpecifier(local) {
1265
+ return {
1266
+ type: "ImportNamespaceSpecifier",
1267
+ local,
1268
+ ...span
1269
+ };
1270
+ },
1271
+ importAttribute(key, value) {
1272
+ return {
1273
+ type: "ImportAttribute",
1274
+ key,
1275
+ value,
1276
+ ...span
1277
+ };
1278
+ },
1279
+ exportNamedDeclaration(declaration, specifiers = [], opts = {}) {
1280
+ return {
1281
+ type: "ExportNamedDeclaration",
1282
+ declaration,
1283
+ specifiers,
1284
+ source: opts.source ?? null,
1285
+ attributes: opts.attributes ?? [],
1286
+ ...opts,
1287
+ ...span
1288
+ };
1289
+ },
1290
+ exportDefaultDeclaration(declaration) {
1291
+ return {
1292
+ type: "ExportDefaultDeclaration",
1293
+ declaration,
1294
+ ...span
1295
+ };
1296
+ },
1297
+ exportAllDeclaration(source, opts = {}) {
1298
+ return {
1299
+ type: "ExportAllDeclaration",
1300
+ exported: opts.exported ?? null,
1301
+ source,
1302
+ attributes: opts.attributes ?? [],
1303
+ ...opts,
1304
+ ...span
1305
+ };
1306
+ },
1307
+ exportSpecifier(local, exported) {
1308
+ return {
1309
+ type: "ExportSpecifier",
1310
+ local,
1311
+ exported,
1312
+ ...span
1313
+ };
1314
+ },
1315
+ jsxIdentifier(name) {
1316
+ return {
1317
+ type: "JSXIdentifier",
1318
+ name,
1319
+ ...span
1320
+ };
1321
+ },
1322
+ jsxNamespacedName(namespace, name) {
1323
+ return {
1324
+ type: "JSXNamespacedName",
1325
+ namespace,
1326
+ name,
1327
+ ...span
1328
+ };
1329
+ },
1330
+ jsxMemberExpression(object, property) {
1331
+ return {
1332
+ type: "JSXMemberExpression",
1333
+ object,
1334
+ property,
1335
+ ...span
1336
+ };
1337
+ },
1338
+ jsxElement(openingElement, children = [], closingElement = null) {
1339
+ return {
1340
+ type: "JSXElement",
1341
+ openingElement,
1342
+ children,
1343
+ closingElement,
1344
+ ...span
1345
+ };
1346
+ },
1347
+ jsxOpeningElement(name, attributes = [], selfClosing = false) {
1348
+ return {
1349
+ type: "JSXOpeningElement",
1350
+ name,
1351
+ attributes,
1352
+ selfClosing,
1353
+ ...span
1354
+ };
1355
+ },
1356
+ jsxClosingElement(name) {
1357
+ return {
1358
+ type: "JSXClosingElement",
1359
+ name,
1360
+ ...span
1361
+ };
1362
+ },
1363
+ jsxOpeningFragment() {
1364
+ return {
1365
+ type: "JSXOpeningFragment",
1366
+ ...span
1367
+ };
1368
+ },
1369
+ jsxClosingFragment() {
1370
+ return {
1371
+ type: "JSXClosingFragment",
1372
+ ...span
1373
+ };
1374
+ },
1375
+ jsxFragment(children = []) {
1376
+ return {
1377
+ type: "JSXFragment",
1378
+ openingFragment: b.jsxOpeningFragment(),
1379
+ children,
1380
+ closingFragment: b.jsxClosingFragment(),
1381
+ ...span
1382
+ };
1383
+ },
1384
+ jsxAttribute(name, value = null) {
1385
+ return {
1386
+ type: "JSXAttribute",
1387
+ name,
1388
+ value,
1389
+ ...span
1390
+ };
1391
+ },
1392
+ jsxSpreadAttribute(argument) {
1393
+ return {
1394
+ type: "JSXSpreadAttribute",
1395
+ argument,
1396
+ ...span
1397
+ };
1398
+ },
1399
+ jsxExpressionContainer(expression) {
1400
+ return {
1401
+ type: "JSXExpressionContainer",
1402
+ expression,
1403
+ ...span
1404
+ };
1405
+ },
1406
+ jsxEmptyExpression() {
1407
+ return {
1408
+ type: "JSXEmptyExpression",
1409
+ ...span
1410
+ };
1411
+ },
1412
+ jsxText(value) {
1413
+ return {
1414
+ type: "JSXText",
1415
+ value,
1416
+ raw: value,
1417
+ ...span
1418
+ };
1419
+ },
1420
+ jsxSpreadChild(expression) {
1421
+ return {
1422
+ type: "JSXSpreadChild",
1423
+ expression,
1424
+ ...span
1425
+ };
1426
+ },
1427
+ tsTypeAnnotation(typeAnnotation) {
1428
+ return {
1429
+ type: "TSTypeAnnotation",
1430
+ typeAnnotation,
1431
+ ...span
1432
+ };
1433
+ },
1434
+ tsAnyKeyword: () => ({
1435
+ type: "TSAnyKeyword",
1436
+ ...span
1437
+ }),
1438
+ tsUnknownKeyword: () => ({
1439
+ type: "TSUnknownKeyword",
1440
+ ...span
1441
+ }),
1442
+ tsNeverKeyword: () => ({
1443
+ type: "TSNeverKeyword",
1444
+ ...span
1445
+ }),
1446
+ tsVoidKeyword: () => ({
1447
+ type: "TSVoidKeyword",
1448
+ ...span
1449
+ }),
1450
+ tsNullKeyword: () => ({
1451
+ type: "TSNullKeyword",
1452
+ ...span
1453
+ }),
1454
+ tsUndefinedKeyword: () => ({
1455
+ type: "TSUndefinedKeyword",
1456
+ ...span
1457
+ }),
1458
+ tsStringKeyword: () => ({
1459
+ type: "TSStringKeyword",
1460
+ ...span
1461
+ }),
1462
+ tsNumberKeyword: () => ({
1463
+ type: "TSNumberKeyword",
1464
+ ...span
1465
+ }),
1466
+ tsBigIntKeyword: () => ({
1467
+ type: "TSBigIntKeyword",
1468
+ ...span
1469
+ }),
1470
+ tsBooleanKeyword: () => ({
1471
+ type: "TSBooleanKeyword",
1472
+ ...span
1473
+ }),
1474
+ tsSymbolKeyword: () => ({
1475
+ type: "TSSymbolKeyword",
1476
+ ...span
1477
+ }),
1478
+ tsObjectKeyword: () => ({
1479
+ type: "TSObjectKeyword",
1480
+ ...span
1481
+ }),
1482
+ tsIntrinsicKeyword: () => ({
1483
+ type: "TSIntrinsicKeyword",
1484
+ ...span
1485
+ }),
1486
+ tsThisType: () => ({
1487
+ type: "TSThisType",
1488
+ ...span
1489
+ }),
1490
+ tsTypeReference(typeName, typeArguments = null) {
1491
+ return {
1492
+ type: "TSTypeReference",
1493
+ typeName,
1494
+ typeArguments,
1495
+ ...span
1496
+ };
1497
+ },
1498
+ tsQualifiedName(left, right) {
1499
+ return {
1500
+ type: "TSQualifiedName",
1501
+ left,
1502
+ right,
1503
+ ...span
1504
+ };
1505
+ },
1506
+ tsTypeQuery(exprName, typeArguments = null) {
1507
+ return {
1508
+ type: "TSTypeQuery",
1509
+ exprName,
1510
+ typeArguments,
1511
+ ...span
1512
+ };
1513
+ },
1514
+ tsImportType(source, opts = {}) {
1515
+ return {
1516
+ type: "TSImportType",
1517
+ source,
1518
+ options: opts.options ?? null,
1519
+ qualifier: opts.qualifier ?? null,
1520
+ typeArguments: opts.typeArguments ?? null,
1521
+ ...span
1522
+ };
1523
+ },
1524
+ tsTypeParameter(name, opts = {}) {
1525
+ return {
1526
+ type: "TSTypeParameter",
1527
+ name,
1528
+ constraint: opts.constraint ?? null,
1529
+ default: opts.default ?? null,
1530
+ in: opts.in ?? false,
1531
+ out: opts.out ?? false,
1532
+ const: opts.const ?? false,
1533
+ ...span
1534
+ };
1535
+ },
1536
+ tsTypeParameterDeclaration(params) {
1537
+ return {
1538
+ type: "TSTypeParameterDeclaration",
1539
+ params,
1540
+ ...span
1541
+ };
1542
+ },
1543
+ tsTypeParameterInstantiation(params) {
1544
+ return {
1545
+ type: "TSTypeParameterInstantiation",
1546
+ params,
1547
+ ...span
1548
+ };
1549
+ },
1550
+ tsLiteralType(literal) {
1551
+ return {
1552
+ type: "TSLiteralType",
1553
+ literal,
1554
+ ...span
1555
+ };
1556
+ },
1557
+ tsTemplateLiteralType(quasis, types) {
1558
+ return {
1559
+ type: "TSTemplateLiteralType",
1560
+ quasis,
1561
+ types,
1562
+ ...span
1563
+ };
1564
+ },
1565
+ tsArrayType(elementType) {
1566
+ return {
1567
+ type: "TSArrayType",
1568
+ elementType,
1569
+ ...span
1570
+ };
1571
+ },
1572
+ tsIndexedAccessType(objectType, indexType) {
1573
+ return {
1574
+ type: "TSIndexedAccessType",
1575
+ objectType,
1576
+ indexType,
1577
+ ...span
1578
+ };
1579
+ },
1580
+ tsTupleType(elementTypes) {
1581
+ return {
1582
+ type: "TSTupleType",
1583
+ elementTypes,
1584
+ ...span
1585
+ };
1586
+ },
1587
+ tsNamedTupleMember(label, elementType, optional = false) {
1588
+ return {
1589
+ type: "TSNamedTupleMember",
1590
+ label,
1591
+ elementType,
1592
+ optional,
1593
+ ...span
1594
+ };
1595
+ },
1596
+ tsOptionalType(typeAnnotation) {
1597
+ return {
1598
+ type: "TSOptionalType",
1599
+ typeAnnotation,
1600
+ ...span
1601
+ };
1602
+ },
1603
+ tsRestType(typeAnnotation) {
1604
+ return {
1605
+ type: "TSRestType",
1606
+ typeAnnotation,
1607
+ ...span
1608
+ };
1609
+ },
1610
+ tsJSDocNullableType(typeAnnotation, postfix = false) {
1611
+ return {
1612
+ type: "TSJSDocNullableType",
1613
+ typeAnnotation,
1614
+ postfix,
1615
+ ...span
1616
+ };
1617
+ },
1618
+ tsJSDocNonNullableType(typeAnnotation, postfix = false) {
1619
+ return {
1620
+ type: "TSJSDocNonNullableType",
1621
+ typeAnnotation,
1622
+ postfix,
1623
+ ...span
1624
+ };
1625
+ },
1626
+ tsJSDocUnknownType() {
1627
+ return {
1628
+ type: "TSJSDocUnknownType",
1629
+ ...span
1630
+ };
1631
+ },
1632
+ tsUnionType(types) {
1633
+ return {
1634
+ type: "TSUnionType",
1635
+ types,
1636
+ ...span
1637
+ };
1638
+ },
1639
+ tsIntersectionType(types) {
1640
+ return {
1641
+ type: "TSIntersectionType",
1642
+ types,
1643
+ ...span
1644
+ };
1645
+ },
1646
+ tsConditionalType(checkType, extendsType, trueType, falseType) {
1647
+ return {
1648
+ type: "TSConditionalType",
1649
+ checkType,
1650
+ extendsType,
1651
+ trueType,
1652
+ falseType,
1653
+ ...span
1654
+ };
1655
+ },
1656
+ tsInferType(typeParameter) {
1657
+ return {
1658
+ type: "TSInferType",
1659
+ typeParameter,
1660
+ ...span
1661
+ };
1662
+ },
1663
+ tsTypeOperator(operator, typeAnnotation) {
1664
+ return {
1665
+ type: "TSTypeOperator",
1666
+ operator,
1667
+ typeAnnotation,
1668
+ ...span
1669
+ };
1670
+ },
1671
+ tsParenthesizedType(typeAnnotation) {
1672
+ return {
1673
+ type: "TSParenthesizedType",
1674
+ typeAnnotation,
1675
+ ...span
1676
+ };
1677
+ },
1678
+ tsFunctionType(params, returnType, typeParameters = null) {
1679
+ return {
1680
+ type: "TSFunctionType",
1681
+ typeParameters,
1682
+ params,
1683
+ returnType,
1684
+ ...span
1685
+ };
1686
+ },
1687
+ tsConstructorType(params, returnType, opts = {}) {
1688
+ return {
1689
+ type: "TSConstructorType",
1690
+ abstract: opts.abstract ?? false,
1691
+ typeParameters: opts.typeParameters ?? null,
1692
+ params,
1693
+ returnType,
1694
+ ...span
1695
+ };
1696
+ },
1697
+ tsTypePredicate(parameterName, typeAnnotation = null, asserts = false) {
1698
+ return {
1699
+ type: "TSTypePredicate",
1700
+ parameterName,
1701
+ typeAnnotation,
1702
+ asserts,
1703
+ ...span
1704
+ };
1705
+ },
1706
+ tsTypeLiteral(members) {
1707
+ return {
1708
+ type: "TSTypeLiteral",
1709
+ members,
1710
+ ...span
1711
+ };
1712
+ },
1713
+ tsMappedType(key, constraint, opts = {}) {
1714
+ return {
1715
+ type: "TSMappedType",
1716
+ key,
1717
+ constraint,
1718
+ nameType: opts.nameType ?? null,
1719
+ typeAnnotation: opts.typeAnnotation ?? null,
1720
+ optional: opts.optional ?? false,
1721
+ readonly: opts.readonly ?? null,
1722
+ ...span
1723
+ };
1724
+ },
1725
+ tsPropertySignature(key, opts = {}) {
1726
+ return {
1727
+ type: "TSPropertySignature",
1728
+ key,
1729
+ typeAnnotation: opts.typeAnnotation ?? null,
1730
+ computed: opts.computed ?? isComputedKey(key),
1731
+ optional: opts.optional ?? false,
1732
+ readonly: opts.readonly ?? false,
1733
+ accessibility: null,
1734
+ static: false,
1735
+ ...span
1736
+ };
1737
+ },
1738
+ tsMethodSignature(key, params, opts = {}) {
1739
+ return {
1740
+ type: "TSMethodSignature",
1741
+ key,
1742
+ computed: opts.computed ?? isComputedKey(key),
1743
+ optional: opts.optional ?? false,
1744
+ kind: opts.kind ?? "method",
1745
+ typeParameters: opts.typeParameters ?? null,
1746
+ params,
1747
+ returnType: opts.returnType ?? null,
1748
+ accessibility: null,
1749
+ readonly: false,
1750
+ static: false,
1751
+ ...span
1752
+ };
1753
+ },
1754
+ tsCallSignatureDeclaration(params, returnType = null, typeParameters = null) {
1755
+ return {
1756
+ type: "TSCallSignatureDeclaration",
1757
+ typeParameters,
1758
+ params,
1759
+ returnType,
1760
+ ...span
1761
+ };
1762
+ },
1763
+ tsConstructSignatureDeclaration(params, returnType = null, typeParameters = null) {
1764
+ return {
1765
+ type: "TSConstructSignatureDeclaration",
1766
+ typeParameters,
1767
+ params,
1768
+ returnType,
1769
+ ...span
1770
+ };
1771
+ },
1772
+ tsIndexSignature(parameters, typeAnnotation, opts = {}) {
1773
+ return {
1774
+ type: "TSIndexSignature",
1775
+ parameters,
1776
+ typeAnnotation,
1777
+ readonly: opts.readonly ?? false,
1778
+ static: opts.static ?? false,
1779
+ accessibility: null,
1780
+ ...span
1781
+ };
1782
+ },
1783
+ tsTypeAliasDeclaration(id, typeAnnotation, opts = {}) {
1784
+ return {
1785
+ type: "TSTypeAliasDeclaration",
1786
+ id,
1787
+ typeParameters: opts.typeParameters ?? null,
1788
+ typeAnnotation,
1789
+ declare: opts.declare ?? false,
1790
+ ...span
1791
+ };
1792
+ },
1793
+ tsInterfaceDeclaration(id, body, opts = {}) {
1794
+ return {
1795
+ type: "TSInterfaceDeclaration",
1796
+ id,
1797
+ typeParameters: opts.typeParameters ?? null,
1798
+ extends: opts.extends ?? [],
1799
+ body,
1800
+ declare: opts.declare ?? false,
1801
+ ...span
1802
+ };
1803
+ },
1804
+ tsInterfaceBody(body) {
1805
+ return {
1806
+ type: "TSInterfaceBody",
1807
+ body,
1808
+ ...span
1809
+ };
1810
+ },
1811
+ tsInterfaceHeritage(expression, typeArguments = null) {
1812
+ return {
1813
+ type: "TSInterfaceHeritage",
1814
+ expression,
1815
+ typeArguments,
1816
+ ...span
1817
+ };
1818
+ },
1819
+ tsClassImplements(expression, typeArguments = null) {
1820
+ return {
1821
+ type: "TSClassImplements",
1822
+ expression,
1823
+ typeArguments,
1824
+ ...span
1825
+ };
1826
+ },
1827
+ tsEnumDeclaration(id, body, opts = {}) {
1828
+ return {
1829
+ type: "TSEnumDeclaration",
1830
+ id,
1831
+ body,
1832
+ const: opts.const ?? false,
1833
+ declare: opts.declare ?? false,
1834
+ ...span
1835
+ };
1836
+ },
1837
+ tsEnumBody(members) {
1838
+ return {
1839
+ type: "TSEnumBody",
1840
+ members,
1841
+ ...span
1842
+ };
1843
+ },
1844
+ tsEnumMember(id, initializer = null) {
1845
+ return {
1846
+ type: "TSEnumMember",
1847
+ id,
1848
+ initializer,
1849
+ computed: false,
1850
+ ...span
1851
+ };
1852
+ },
1853
+ tsModuleDeclaration(id, body, opts = {}) {
1854
+ return {
1855
+ type: "TSModuleDeclaration",
1856
+ id,
1857
+ body,
1858
+ kind: opts.kind ?? "module",
1859
+ declare: opts.declare ?? false,
1860
+ global: opts.global ?? false,
1861
+ ...span
1862
+ };
1863
+ },
1864
+ tsModuleBlock(body = []) {
1865
+ return {
1866
+ type: "TSModuleBlock",
1867
+ body,
1868
+ ...span
1869
+ };
1870
+ },
1871
+ tsParameterProperty(parameter, opts = {}) {
1872
+ return {
1873
+ type: "TSParameterProperty",
1874
+ decorators: opts.decorators ?? [],
1875
+ parameter,
1876
+ override: opts.override ?? false,
1877
+ readonly: opts.readonly ?? false,
1878
+ accessibility: opts.accessibility ?? null,
1879
+ static: false,
1880
+ ...span
1881
+ };
1882
+ },
1883
+ tsAsExpression(expression, typeAnnotation) {
1884
+ return {
1885
+ type: "TSAsExpression",
1886
+ expression,
1887
+ typeAnnotation,
1888
+ ...span
1889
+ };
1890
+ },
1891
+ tsSatisfiesExpression(expression, typeAnnotation) {
1892
+ return {
1893
+ type: "TSSatisfiesExpression",
1894
+ expression,
1895
+ typeAnnotation,
1896
+ ...span
1897
+ };
1898
+ },
1899
+ tsTypeAssertion(typeAnnotation, expression) {
1900
+ return {
1901
+ type: "TSTypeAssertion",
1902
+ typeAnnotation,
1903
+ expression,
1904
+ ...span
1905
+ };
1906
+ },
1907
+ tsNonNullExpression(expression) {
1908
+ return {
1909
+ type: "TSNonNullExpression",
1910
+ expression,
1911
+ ...span
1912
+ };
1913
+ },
1914
+ tsInstantiationExpression(expression, typeArguments) {
1915
+ return {
1916
+ type: "TSInstantiationExpression",
1917
+ expression,
1918
+ typeArguments,
1919
+ ...span
1920
+ };
1921
+ },
1922
+ tsExportAssignment(expression) {
1923
+ return {
1924
+ type: "TSExportAssignment",
1925
+ expression,
1926
+ ...span
1927
+ };
1928
+ },
1929
+ tsNamespaceExportDeclaration(id) {
1930
+ return {
1931
+ type: "TSNamespaceExportDeclaration",
1932
+ id,
1933
+ ...span
1934
+ };
1935
+ },
1936
+ tsImportEqualsDeclaration(id, moduleReference, importKind = "value") {
1937
+ return {
1938
+ type: "TSImportEqualsDeclaration",
1939
+ id,
1940
+ moduleReference,
1941
+ importKind,
1942
+ ...span
1943
+ };
1944
+ },
1945
+ tsExternalModuleReference(expression) {
1946
+ return {
1947
+ type: "TSExternalModuleReference",
1948
+ expression,
1949
+ ...span
1950
+ };
1951
+ },
1952
+ tsDeclareFunction(id, params, opts = {}) {
1953
+ return {
1954
+ type: "TSDeclareFunction",
1955
+ id,
1956
+ generator: opts.generator ?? false,
1957
+ async: opts.async ?? false,
1958
+ params,
1959
+ body: null,
1960
+ expression: false,
1961
+ declare: opts.declare ?? false,
1962
+ typeParameters: opts.typeParameters ?? null,
1963
+ returnType: opts.returnType ?? null,
1964
+ ...span
1965
+ };
1966
+ },
1967
+ tsEmptyBodyFunctionExpression(params, opts = {}) {
1968
+ return {
1969
+ type: "TSEmptyBodyFunctionExpression",
1970
+ id: opts.id ?? null,
1971
+ generator: false,
1972
+ async: false,
1973
+ params,
1974
+ body: null,
1975
+ expression: false,
1976
+ declare: false,
1977
+ typeParameters: opts.typeParameters ?? null,
1978
+ returnType: opts.returnType ?? null,
1979
+ ...span
1980
+ };
1981
+ },
1982
+ hashbang(value) {
1983
+ return {
1984
+ type: "Hashbang",
1985
+ value,
1986
+ ...span
1987
+ };
1988
+ },
1989
+ program(body = [], opts = {}) {
1990
+ return {
1991
+ type: "Program",
1992
+ sourceType: opts.sourceType ?? "module",
1993
+ hashbang: opts.hashbang ?? null,
1994
+ body,
1995
+ ...span
1996
+ };
1997
+ }
1998
+ };
1999
+ //#endregion
2000
+ //#region src/walk/core.ts
2001
+ /** Returned up the stack when a visitor calls `remove()`. */
2002
+ const REMOVED = Symbol("yuku-ast/removed");
2003
+ /** A node viewed as its fields, for traversal and mutation by key. */
2004
+ const fieldsOf = (node) => node;
2005
+ /**
2006
+ * One per visited node, holding its own position and a link to its parent path
2007
+ * so it stays valid, ancestors included, after the visit returns. Control flow
2008
+ * and mutation delegate to the owning walker.
2009
+ */
2010
+ var NodePath = class {
2011
+ walker;
2012
+ parentPath;
2013
+ node;
2014
+ parent;
2015
+ key;
2016
+ index;
2017
+ constructor(walker, parentPath, node, parent, key, index) {
2018
+ this.walker = walker;
2019
+ this.parentPath = parentPath;
2020
+ this.node = node;
2021
+ this.parent = parent;
2022
+ this.key = key;
2023
+ this.index = index;
2024
+ }
2025
+ get state() {
2026
+ return this.walker.state;
2027
+ }
2028
+ set state(value) {
2029
+ this.walker.state = value;
2030
+ }
2031
+ get ancestors() {
2032
+ const out = [];
2033
+ for (let p = this.parentPath; p !== null; p = p.parentPath) out.push(p.node);
2034
+ return out.reverse();
2035
+ }
2036
+ skip() {
2037
+ this.walker.skipFlag = true;
2038
+ }
2039
+ stop() {
2040
+ this.walker.stopFlag = true;
2041
+ }
2042
+ replace(next) {
2043
+ if (next.start === 0 && next.end === 0) {
2044
+ next.start = this.node.start;
2045
+ next.end = this.node.end;
2046
+ }
2047
+ this.node = next;
2048
+ this.walker.replacement = next;
2049
+ const { parent, key, index } = this;
2050
+ if (parent === null || key === null) return;
2051
+ const fields = fieldsOf(parent);
2052
+ if (index === null) fields[key] = next;
2053
+ else fields[key][index] = next;
2054
+ }
2055
+ remove() {
2056
+ if (this.parent === null) throw new Error("yuku-ast: cannot remove the root node");
2057
+ this.walker.removeFlag = true;
2058
+ }
2059
+ insertBefore(node) {
2060
+ this.insertSibling(node, 0);
2061
+ }
2062
+ insertAfter(node) {
2063
+ this.insertSibling(node, 1);
2064
+ }
2065
+ insertSibling(node, offset) {
2066
+ const { parent, key, index } = this;
2067
+ if (parent === null || key === null || index === null) throw new Error("yuku-ast: insertBefore/insertAfter require a node in an array field");
2068
+ const list = fieldsOf(parent)[key];
2069
+ const at = list.indexOf(this.node);
2070
+ if (at !== -1) list.splice(at + offset, 0, node);
2071
+ }
2072
+ };
2073
+ /** Shared dispatch and traversal state. The sync and async drivers extend this. */
2074
+ var WalkerCore = class {
2075
+ state;
2076
+ skipFlag = false;
2077
+ stopFlag = false;
2078
+ removeFlag = false;
2079
+ replacement = null;
2080
+ universalEnter;
2081
+ universalLeave;
2082
+ concrete = /* @__PURE__ */ new Map();
2083
+ aliasHandlers = [];
2084
+ cache = Object.create(null);
2085
+ constructor(visitors, state) {
2086
+ this.state = state;
2087
+ const entries = visitors;
2088
+ const aliases = ALIAS_GROUPS;
2089
+ for (const name in entries) {
2090
+ const entry = entries[name];
2091
+ if (!entry) continue;
2092
+ if (name === "enter") {
2093
+ if (typeof entry === "function") this.universalEnter = entry;
2094
+ continue;
2095
+ }
2096
+ if (name === "leave") {
2097
+ if (typeof entry === "function") this.universalLeave = entry;
2098
+ continue;
2099
+ }
2100
+ const enter = typeof entry === "function" ? entry : entry.enter;
2101
+ const leave = typeof entry === "function" ? void 0 : entry.leave;
2102
+ const aliasTypes = aliases[name];
2103
+ if (aliasTypes) this.aliasHandlers.push({
2104
+ types: new Set(aliasTypes),
2105
+ enter,
2106
+ leave
2107
+ });
2108
+ else {
2109
+ const prev = this.concrete.get(name);
2110
+ this.concrete.set(name, {
2111
+ enter: enter ?? prev?.enter,
2112
+ leave: leave ?? prev?.leave
2113
+ });
2114
+ }
2115
+ }
2116
+ }
2117
+ dispatchFor(type) {
2118
+ const cached = this.cache[type];
2119
+ if (cached !== void 0) return cached;
2120
+ const enter = [];
2121
+ const leave = [];
2122
+ const concrete = this.concrete.get(type);
2123
+ if (this.universalEnter) enter.push(this.universalEnter);
2124
+ for (let i = 0; i < this.aliasHandlers.length; i++) {
2125
+ const a = this.aliasHandlers[i];
2126
+ if (a.enter && a.types.has(type)) enter.push(a.enter);
2127
+ }
2128
+ if (concrete?.enter) enter.push(concrete.enter);
2129
+ if (concrete?.leave) leave.push(concrete.leave);
2130
+ for (let i = this.aliasHandlers.length - 1; i >= 0; i--) {
2131
+ const a = this.aliasHandlers[i];
2132
+ if (a.leave && a.types.has(type)) leave.push(a.leave);
2133
+ }
2134
+ if (this.universalLeave) leave.push(this.universalLeave);
2135
+ return this.cache[type] = {
2136
+ enter,
2137
+ leave,
2138
+ keys: VISITOR_KEYS[type]
2139
+ };
2140
+ }
2141
+ newPath(parentPath, parent, node, key, index) {
2142
+ return new NodePath(this, parentPath, node, parent, key, index);
2143
+ }
2144
+ };
2145
+ //#endregion
2146
+ //#region src/walk/sync.ts
2147
+ var Walker = class extends WalkerCore {
2148
+ run(root) {
2149
+ const result = this.visit(null, null, root, null, null);
2150
+ return result === REMOVED ? root : result;
2151
+ }
2152
+ apply(handlers, node, path) {
2153
+ this.removeFlag = false;
2154
+ for (let i = 0; i < handlers.length; i++) {
2155
+ this.replacement = null;
2156
+ handlers[i](node, path);
2157
+ if (this.replacement !== null) node = this.replacement;
2158
+ if (this.removeFlag || this.stopFlag) break;
2159
+ }
2160
+ return node;
2161
+ }
2162
+ visit(parentPath, parent, node, key, index) {
2163
+ if (this.stopFlag) return node;
2164
+ const path = this.newPath(parentPath, parent, node, key, index);
2165
+ this.skipFlag = false;
2166
+ let dispatch = this.dispatchFor(node.type);
2167
+ if (dispatch.enter.length > 0) {
2168
+ const before = node;
2169
+ node = this.apply(dispatch.enter, node, path);
2170
+ if (this.removeFlag) return REMOVED;
2171
+ if (this.stopFlag) return node;
2172
+ if (node !== before) dispatch = this.dispatchFor(node.type);
2173
+ }
2174
+ if (!this.skipFlag && dispatch.keys.length > 0) {
2175
+ this.descend(path, node, dispatch.keys);
2176
+ if (this.stopFlag) return node;
2177
+ }
2178
+ if (dispatch.leave.length > 0) {
2179
+ node = this.apply(dispatch.leave, node, path);
2180
+ if (this.removeFlag) return REMOVED;
2181
+ if (this.stopFlag) return node;
2182
+ }
2183
+ return node;
2184
+ }
2185
+ descend(path, node, keys) {
2186
+ const fields = fieldsOf(node);
2187
+ for (let k = 0; k < keys.length; k++) {
2188
+ const key = keys[k];
2189
+ const value = fields[key];
2190
+ if (value == null) continue;
2191
+ if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
2192
+ const child = value[i];
2193
+ if (child == null) continue;
2194
+ const before = value.length;
2195
+ if (this.visit(path, node, child, key, i) === REMOVED) {
2196
+ value.splice(i, 1);
2197
+ i--;
2198
+ } else i += value.length - before;
2199
+ if (this.stopFlag) return;
2200
+ }
2201
+ else {
2202
+ if (this.visit(path, node, value, key, null) === REMOVED) fields[key] = null;
2203
+ if (this.stopFlag) return;
2204
+ }
2205
+ }
2206
+ }
2207
+ };
2208
+ /**
2209
+ * Walk an AST depth first, dispatching to typed visitors and mutating in place.
2210
+ *
2211
+ * @param root The node to start from, usually a `Program`.
2212
+ * @param visitors Handlers keyed by node `type`, alias group, or `enter`/`leave`.
2213
+ * @param state Optional value exposed as `path.state` throughout the walk.
2214
+ * @returns The root node, or its replacement if the root was replaced.
2215
+ *
2216
+ * @example
2217
+ * ```ts
2218
+ * walk(program, {
2219
+ * Identifier(node) {
2220
+ * console.log(node.name);
2221
+ * },
2222
+ * CallExpression(node, path) {
2223
+ * if (node.callee.type === "MemberExpression") path.skip();
2224
+ * },
2225
+ * });
2226
+ * ```
2227
+ */
2228
+ function walk(root, visitors, state) {
2229
+ return new Walker(visitors, state).run(root);
2230
+ }
2231
+ //#endregion
2232
+ //#region src/walk/async.ts
2233
+ var AsyncWalker = class extends WalkerCore {
2234
+ async run(root) {
2235
+ const result = await this.visit(null, null, root, null, null);
2236
+ return result === REMOVED ? root : result;
2237
+ }
2238
+ async apply(handlers, node, path) {
2239
+ this.removeFlag = false;
2240
+ for (let i = 0; i < handlers.length; i++) {
2241
+ this.replacement = null;
2242
+ await handlers[i](node, path);
2243
+ if (this.replacement !== null) node = this.replacement;
2244
+ if (this.removeFlag || this.stopFlag) break;
2245
+ }
2246
+ return node;
2247
+ }
2248
+ async visit(parentPath, parent, node, key, index) {
2249
+ if (this.stopFlag) return node;
2250
+ const path = this.newPath(parentPath, parent, node, key, index);
2251
+ this.skipFlag = false;
2252
+ let dispatch = this.dispatchFor(node.type);
2253
+ if (dispatch.enter.length > 0) {
2254
+ const before = node;
2255
+ node = await this.apply(dispatch.enter, node, path);
2256
+ if (this.removeFlag) return REMOVED;
2257
+ if (this.stopFlag) return node;
2258
+ if (node !== before) dispatch = this.dispatchFor(node.type);
2259
+ }
2260
+ if (!this.skipFlag && dispatch.keys.length > 0) {
2261
+ await this.descend(path, node, dispatch.keys);
2262
+ if (this.stopFlag) return node;
2263
+ }
2264
+ if (dispatch.leave.length > 0) {
2265
+ node = await this.apply(dispatch.leave, node, path);
2266
+ if (this.removeFlag) return REMOVED;
2267
+ if (this.stopFlag) return node;
2268
+ }
2269
+ return node;
2270
+ }
2271
+ async descend(path, node, keys) {
2272
+ const fields = fieldsOf(node);
2273
+ for (let k = 0; k < keys.length; k++) {
2274
+ const key = keys[k];
2275
+ const value = fields[key];
2276
+ if (value == null) continue;
2277
+ if (Array.isArray(value)) for (let i = 0; i < value.length; i++) {
2278
+ const child = value[i];
2279
+ if (child == null) continue;
2280
+ const before = value.length;
2281
+ if (await this.visit(path, node, child, key, i) === REMOVED) {
2282
+ value.splice(i, 1);
2283
+ i--;
2284
+ } else i += value.length - before;
2285
+ if (this.stopFlag) return;
2286
+ }
2287
+ else {
2288
+ if (await this.visit(path, node, value, key, null) === REMOVED) fields[key] = null;
2289
+ if (this.stopFlag) return;
2290
+ }
2291
+ }
2292
+ }
2293
+ };
2294
+ /**
2295
+ * Like {@link walk}, but visitors may be `async`. Handlers are awaited one at a
2296
+ * time in depth-first order, so mutation behaves exactly as in the sync walk.
2297
+ * Reach for this only when a visitor needs to await I/O; prefer {@link walk}
2298
+ * otherwise, as awaiting has per-node overhead.
2299
+ *
2300
+ * @returns A promise of the root node, or its replacement if the root was replaced.
2301
+ */
2302
+ function walkAsync(root, visitors, state) {
2303
+ return new AsyncWalker(visitors, state).run(root);
2304
+ }
2305
+ //#endregion
2306
+ export { b, is, walk, walkAsync };