@yuku-toolchain/types 0.5.32

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 (3) hide show
  1. package/README.md +13 -0
  2. package/index.d.ts +2013 -0
  3. package/package.json +28 -0
package/index.d.ts ADDED
@@ -0,0 +1,2013 @@
1
+ /** How the source code should be parsed. */
2
+ type SourceType = "script" | "module";
3
+
4
+ type ModuleKind = SourceType;
5
+
6
+ /** Language variant of the source code. */
7
+ type SourceLang = "js" | "ts" | "jsx" | "tsx" | "dts";
8
+ /** Whether a comment came from a line or block source comment. */
9
+ type CommentType = "Line" | "Block";
10
+
11
+ /**
12
+ * A source comment in the flat {@link ParseResult.comments} list, carrying its
13
+ * source span.
14
+ */
15
+ interface Comment {
16
+ type: CommentType;
17
+ /** Comment text without the delimiters. */
18
+ value: string;
19
+ /** Byte offset of the comment start (delimiter included). */
20
+ start: number;
21
+ /** Byte offset of the comment end (delimiter included). */
22
+ end: number;
23
+ }
24
+
25
+ /**
26
+ * Position of an {@link AttachedComment} relative to its host node.
27
+ *
28
+ * - `before`: leading the host.
29
+ * - `after`: trailing the host.
30
+ * - `inside`: interior to an otherwise empty host.
31
+ */
32
+ type CommentPosition = "before" | "after" | "inside";
33
+
34
+ /**
35
+ * A comment attached to a single host AST node, via {@link BaseNode.comments}.
36
+ *
37
+ * `sameLine` is true when the comment shares a source line with the
38
+ * host's adjacent edge (host's start for `before`, host's end for
39
+ * `after`). For `inside` it is always `false`.
40
+ */
41
+ interface AttachedComment {
42
+ type: CommentType;
43
+ position: CommentPosition;
44
+ sameLine: boolean;
45
+ /** Comment text without the delimiters. */
46
+ value: string;
47
+ }
48
+
49
+ /** A labeled source span attached to a {@link Diagnostic}. */
50
+ interface DiagnosticLabel {
51
+ /** Byte offset. */
52
+ start: number;
53
+ /** Byte offset. */
54
+ end: number;
55
+ message: string;
56
+ }
57
+
58
+ /** Severity level of a {@link Diagnostic}. */
59
+ type DiagnosticSeverity = "error" | "warning" | "hint" | "info";
60
+
61
+ /**
62
+ * A diagnostic produced during parsing or semantic analysis.
63
+ * The parser is error tolerant: an AST is always produced even when diagnostics exist.
64
+ */
65
+ interface Diagnostic {
66
+ severity: DiagnosticSeverity;
67
+ message: string;
68
+ /** Fix suggestion, or `null` if unavailable. */
69
+ help: string | null;
70
+ /** Byte offset. */
71
+ start: number;
72
+ /** Byte offset. */
73
+ end: number;
74
+ /** Additional source spans providing context. */
75
+ labels: DiagnosticLabel[];
76
+ }
77
+
78
+ /**
79
+ * A `(line, column)` pair into the source, matching ESTree's `loc` convention.
80
+ * Lines are 1-based; columns are 0-based.
81
+ */
82
+ interface SourceLocation {
83
+ /** 1-based line number. */
84
+ line: number;
85
+ /** 0-based column number within the line. */
86
+ column: number;
87
+ }
88
+ /** Discriminant `type` string of every AST node. */
89
+ type NodeType = Node["type"];
90
+
91
+ /** The node, or union of nodes, carrying a given `type`. */
92
+ type NodeOfType<K extends NodeType> = Extract<Node, { type: K }>;
93
+
94
+ /**
95
+ * The walk context: one reused object exposing the current position and
96
+ * the tree mutation operations. Valid only during the visit that
97
+ * receives it; do not store it.
98
+ */
99
+ declare class WalkContext<T extends Node = Node, S = unknown> {
100
+ /** The node being visited. */
101
+ readonly node: T;
102
+ /** The node that holds {@link node}, or null at the walk root. */
103
+ readonly parent: Node | null;
104
+ /**
105
+ * The field on {@link parent} holding {@link node} (or its array),
106
+ * or null at the walk root.
107
+ */
108
+ readonly key: string | null;
109
+ /** Index within an array field, or null in a plain field. */
110
+ readonly index: number | null;
111
+ /** State threaded through the walk (the third {@link walk} argument). */
112
+ state: S;
113
+ /** Ancestors from the walk root down to {@link parent}. */
114
+ ancestors(): Node[];
115
+ /** Do not descend into the current node's children. */
116
+ skip(): void;
117
+ /** Stop the walk entirely. */
118
+ stop(): void;
119
+ /**
120
+ * Replace the current node. The walk continues into the replacement's
121
+ * children, and `leave` fires for the replacement's type. A synthetic
122
+ * node with `start === 0 && end === 0` inherits the original span,
123
+ * for source maps. Throws at the walk root.
124
+ */
125
+ replace(node: Node): void;
126
+ /**
127
+ * Remove the current node from its parent: spliced from array fields,
128
+ * nulled in plain fields. Children are not walked and `leave` does
129
+ * not fire. Throws at the walk root.
130
+ */
131
+ remove(): void;
132
+ /**
133
+ * Insert a sibling before the current node. The inserted node is NOT
134
+ * visited. Only valid inside an array field.
135
+ */
136
+ insertBefore(node: Node): void;
137
+ /**
138
+ * Insert a sibling after the current node. The inserted node IS
139
+ * visited. Only valid inside an array field.
140
+ */
141
+ insertAfter(node: Node): void;
142
+ }
143
+ /**
144
+ * The scan cursor: one reused object pointing at the current node
145
+ * record in the parse buffer. Valid only during the visit that receives
146
+ * it; do not store it.
147
+ */
148
+ interface ScanCursor<T extends Node = Node> {
149
+ /** The node's `type`. */
150
+ readonly type: T["type"];
151
+ /** Span start, same as the materialized node's `start`. */
152
+ readonly start: number;
153
+ /** Span end, same as the materialized node's `end`. */
154
+ readonly end: number;
155
+ /** The node's index in the parse buffer, stable per parse. */
156
+ readonly index: number;
157
+ /** Materializes the node on demand. */
158
+ node(): T;
159
+ /** Do not descend into the current node's children. */
160
+ skip(): void;
161
+ /** Stop the scan entirely. */
162
+ stop(): void;
163
+ }
164
+ // AST node types
165
+
166
+ interface BaseNode {
167
+ start: number;
168
+ end: number;
169
+ /**
170
+ * Comments attached to this node in source order. Present only when
171
+ * {@link ParseOptions.attachComments} is true.
172
+ */
173
+ comments?: AttachedComment[];
174
+ }
175
+
176
+ type Span = BaseNode;
177
+
178
+ type BinaryOperator =
179
+ | "=="
180
+ | "!="
181
+ | "==="
182
+ | "!=="
183
+ | "<"
184
+ | "<="
185
+ | ">"
186
+ | ">="
187
+ | "+"
188
+ | "-"
189
+ | "*"
190
+ | "/"
191
+ | "%"
192
+ | "**"
193
+ | "|"
194
+ | "^"
195
+ | "&"
196
+ | "<<"
197
+ | ">>"
198
+ | ">>>"
199
+ | "in"
200
+ | "instanceof";
201
+
202
+ type LogicalOperator = "&&" | "||" | "??";
203
+
204
+ type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
205
+
206
+ type UpdateOperator = "++" | "--";
207
+
208
+ type AssignmentOperator =
209
+ | "="
210
+ | "+="
211
+ | "-="
212
+ | "*="
213
+ | "/="
214
+ | "%="
215
+ | "**="
216
+ | "<<="
217
+ | ">>="
218
+ | ">>>="
219
+ | "|="
220
+ | "^="
221
+ | "&="
222
+ | "||="
223
+ | "&&="
224
+ | "??=";
225
+
226
+ type VariableDeclarationKind = "var" | "let" | "const" | "using" | "await using";
227
+
228
+ type PropertyKind = "init" | "get" | "set";
229
+
230
+ type MethodDefinitionKind = "constructor" | "method" | "get" | "set";
231
+
232
+ type TSAccessibility = "public" | "private" | "protected";
233
+
234
+ type TSMethodSignatureKind = "method" | "get" | "set";
235
+
236
+ type TSTypeOperatorOperator = "keyof" | "unique" | "readonly";
237
+
238
+ type TSModuleDeclarationKind = "module" | "namespace" | "global";
239
+
240
+ type TSMappedTypeModifierOperator = true | "+" | "-";
241
+
242
+ type ImportPhase = "source" | "defer";
243
+
244
+ type ImportOrExportKind = "value" | "type";
245
+
246
+ type FunctionType =
247
+ | "FunctionDeclaration"
248
+ | "FunctionExpression"
249
+ | "TSDeclareFunction"
250
+ | "TSEmptyBodyFunctionExpression";
251
+
252
+ type ClassType = "ClassDeclaration" | "ClassExpression";
253
+
254
+ type MethodDefinitionType = "MethodDefinition" | "TSAbstractMethodDefinition";
255
+
256
+ type PropertyDefinitionType = "PropertyDefinition" | "TSAbstractPropertyDefinition";
257
+
258
+ type AccessorPropertyType = "AccessorProperty" | "TSAbstractAccessorProperty";
259
+
260
+ interface Identifier extends BaseNode {
261
+ type: "Identifier";
262
+ name: string;
263
+ decorators?: Decorator[];
264
+ optional?: boolean;
265
+ typeAnnotation?: TSTypeAnnotation | null;
266
+ }
267
+
268
+ type IdentifierName = Identifier;
269
+ type IdentifierReference = Identifier;
270
+ type BindingIdentifier = Identifier;
271
+ type LabelIdentifier = Identifier;
272
+
273
+ interface PrivateIdentifier extends BaseNode {
274
+ type: "PrivateIdentifier";
275
+ name: string;
276
+ }
277
+
278
+ interface StringLiteral extends BaseNode {
279
+ type: "Literal";
280
+ value: string;
281
+ raw: string;
282
+ }
283
+
284
+ interface NumericLiteral extends BaseNode {
285
+ type: "Literal";
286
+ value: number | null;
287
+ raw: string;
288
+ }
289
+
290
+ interface BigIntLiteral extends BaseNode {
291
+ type: "Literal";
292
+ value: bigint;
293
+ raw: string;
294
+ bigint: string;
295
+ }
296
+
297
+ interface BooleanLiteral extends BaseNode {
298
+ type: "Literal";
299
+ value: boolean;
300
+ raw: string;
301
+ }
302
+
303
+ interface NullLiteral extends BaseNode {
304
+ type: "Literal";
305
+ value: null;
306
+ raw: "null";
307
+ }
308
+
309
+ interface RegExpLiteral extends BaseNode {
310
+ type: "Literal";
311
+ value: RegExp | null;
312
+ raw: string;
313
+ regex: {
314
+ pattern: string;
315
+ flags: string;
316
+ };
317
+ }
318
+
319
+ type Literal =
320
+ | StringLiteral
321
+ | NumericLiteral
322
+ | BigIntLiteral
323
+ | BooleanLiteral
324
+ | NullLiteral
325
+ | RegExpLiteral;
326
+
327
+ interface ArrayPattern extends BaseNode {
328
+ type: "ArrayPattern";
329
+ elements: Array<BindingPattern | RestElement | null>;
330
+ decorators?: Decorator[];
331
+ optional?: boolean;
332
+ typeAnnotation?: TSTypeAnnotation | null;
333
+ }
334
+
335
+ interface ObjectPattern extends BaseNode {
336
+ type: "ObjectPattern";
337
+ properties: Array<BindingProperty | RestElement>;
338
+ decorators?: Decorator[];
339
+ optional?: boolean;
340
+ typeAnnotation?: TSTypeAnnotation | null;
341
+ }
342
+
343
+ interface AssignmentPattern extends BaseNode {
344
+ type: "AssignmentPattern";
345
+ left: BindingPattern;
346
+ right: Expression;
347
+ decorators?: Decorator[];
348
+ optional?: boolean;
349
+ typeAnnotation?: TSTypeAnnotation | null;
350
+ }
351
+
352
+ interface RestElement extends BaseNode {
353
+ type: "RestElement";
354
+ argument: BindingPattern;
355
+ decorators?: Decorator[];
356
+ optional?: boolean;
357
+ typeAnnotation?: TSTypeAnnotation | null;
358
+ value?: null;
359
+ }
360
+
361
+ type BindingPattern = BindingIdentifier | ArrayPattern | ObjectPattern | AssignmentPattern;
362
+
363
+ type FunctionParameter = BindingPattern | RestElement | TSParameterProperty;
364
+
365
+ interface ObjectProperty extends BaseNode {
366
+ type: "Property";
367
+ kind: PropertyKind;
368
+ key: PropertyKey;
369
+ value: Expression;
370
+ method: boolean;
371
+ shorthand: boolean;
372
+ computed: boolean;
373
+ optional?: false;
374
+ }
375
+
376
+ interface BindingProperty extends BaseNode {
377
+ type: "Property";
378
+ kind: "init";
379
+ key: PropertyKey;
380
+ value: BindingPattern;
381
+ method: false;
382
+ shorthand: boolean;
383
+ computed: boolean;
384
+ optional?: false;
385
+ }
386
+
387
+ type Property = ObjectProperty | BindingProperty;
388
+
389
+ type PropertyKey = IdentifierName | PrivateIdentifier | Expression;
390
+
391
+ interface SequenceExpression extends BaseNode {
392
+ type: "SequenceExpression";
393
+ expressions: Expression[];
394
+ }
395
+
396
+ interface ParenthesizedExpression extends BaseNode {
397
+ type: "ParenthesizedExpression";
398
+ expression: Expression;
399
+ }
400
+
401
+ interface BinaryExpression extends BaseNode {
402
+ type: "BinaryExpression";
403
+ left: Expression | PrivateIdentifier;
404
+ operator: BinaryOperator;
405
+ right: Expression;
406
+ }
407
+
408
+ interface LogicalExpression extends BaseNode {
409
+ type: "LogicalExpression";
410
+ left: Expression;
411
+ operator: LogicalOperator;
412
+ right: Expression;
413
+ }
414
+
415
+ interface ConditionalExpression extends BaseNode {
416
+ type: "ConditionalExpression";
417
+ test: Expression;
418
+ consequent: Expression;
419
+ alternate: Expression;
420
+ }
421
+
422
+ interface UnaryExpression extends BaseNode {
423
+ type: "UnaryExpression";
424
+ operator: UnaryOperator;
425
+ prefix: true;
426
+ argument: Expression;
427
+ }
428
+
429
+ interface UpdateExpression extends BaseNode {
430
+ type: "UpdateExpression";
431
+ operator: UpdateOperator;
432
+ prefix: boolean;
433
+ argument: Expression;
434
+ }
435
+
436
+ type SimpleAssignmentTarget =
437
+ | IdentifierReference
438
+ | MemberExpression
439
+ | TSAsExpression
440
+ | TSSatisfiesExpression
441
+ | TSNonNullExpression
442
+ | TSTypeAssertion;
443
+
444
+ type AssignmentTargetPattern = ArrayPattern | ObjectPattern;
445
+
446
+ type AssignmentTarget = SimpleAssignmentTarget | AssignmentTargetPattern;
447
+
448
+ interface AssignmentExpression extends BaseNode {
449
+ type: "AssignmentExpression";
450
+ operator: AssignmentOperator;
451
+ left: AssignmentTarget;
452
+ right: Expression;
453
+ }
454
+
455
+ interface YieldExpression extends BaseNode {
456
+ type: "YieldExpression";
457
+ delegate: boolean;
458
+ argument: Expression | null;
459
+ }
460
+
461
+ interface AwaitExpression extends BaseNode {
462
+ type: "AwaitExpression";
463
+ argument: Expression;
464
+ }
465
+
466
+ type ArrayExpressionElement = Expression | SpreadElement | null;
467
+
468
+ type ObjectPropertyKind = ObjectProperty | SpreadElement;
469
+
470
+ type Argument = Expression | SpreadElement;
471
+
472
+ interface ArrayExpression extends BaseNode {
473
+ type: "ArrayExpression";
474
+ elements: ArrayExpressionElement[];
475
+ }
476
+
477
+ interface ObjectExpression extends BaseNode {
478
+ type: "ObjectExpression";
479
+ properties: ObjectPropertyKind[];
480
+ }
481
+
482
+ interface SpreadElement extends BaseNode {
483
+ type: "SpreadElement";
484
+ argument: Expression;
485
+ }
486
+
487
+ interface ComputedMemberExpression extends BaseNode {
488
+ type: "MemberExpression";
489
+ object: Expression | Super;
490
+ property: Expression;
491
+ computed: true;
492
+ optional: boolean;
493
+ }
494
+
495
+ interface StaticMemberExpression extends BaseNode {
496
+ type: "MemberExpression";
497
+ object: Expression | Super;
498
+ property: IdentifierName;
499
+ computed: false;
500
+ optional: boolean;
501
+ }
502
+
503
+ interface PrivateFieldExpression extends BaseNode {
504
+ type: "MemberExpression";
505
+ object: Expression | Super;
506
+ property: PrivateIdentifier;
507
+ computed: false;
508
+ optional: boolean;
509
+ }
510
+
511
+ type MemberExpression = ComputedMemberExpression | StaticMemberExpression | PrivateFieldExpression;
512
+
513
+ interface CallExpression extends BaseNode {
514
+ type: "CallExpression";
515
+ callee: Expression | Super;
516
+ arguments: Argument[];
517
+ optional: boolean;
518
+ typeArguments?: TSTypeParameterInstantiation | null;
519
+ }
520
+
521
+ interface ChainExpression extends BaseNode {
522
+ type: "ChainExpression";
523
+ expression: ChainElement;
524
+ }
525
+
526
+ type ChainElement = CallExpression | MemberExpression | TSNonNullExpression;
527
+
528
+ interface TaggedTemplateExpression extends BaseNode {
529
+ type: "TaggedTemplateExpression";
530
+ tag: Expression;
531
+ quasi: TemplateLiteral;
532
+ typeArguments?: TSTypeParameterInstantiation | null;
533
+ }
534
+
535
+ interface NewExpression extends BaseNode {
536
+ type: "NewExpression";
537
+ callee: Expression;
538
+ arguments: Argument[];
539
+ typeArguments?: TSTypeParameterInstantiation | null;
540
+ }
541
+
542
+ interface MetaProperty extends BaseNode {
543
+ type: "MetaProperty";
544
+ meta: IdentifierName;
545
+ property: IdentifierName;
546
+ }
547
+
548
+ interface ImportExpression extends BaseNode {
549
+ type: "ImportExpression";
550
+ source: Expression;
551
+ options: Expression | null;
552
+ phase: ImportPhase | null;
553
+ }
554
+
555
+ interface TemplateLiteral extends BaseNode {
556
+ type: "TemplateLiteral";
557
+ quasis: TemplateElement[];
558
+ expressions: Expression[];
559
+ }
560
+
561
+ interface TemplateElement extends BaseNode {
562
+ type: "TemplateElement";
563
+ value: {
564
+ raw: string;
565
+ cooked: string | null;
566
+ };
567
+ tail: boolean;
568
+ }
569
+
570
+ interface Super extends BaseNode {
571
+ type: "Super";
572
+ }
573
+
574
+ interface ThisExpression extends BaseNode {
575
+ type: "ThisExpression";
576
+ }
577
+
578
+ interface ExpressionStatement extends BaseNode {
579
+ type: "ExpressionStatement";
580
+ expression: Expression;
581
+ directive?: null;
582
+ }
583
+
584
+ interface Directive extends BaseNode {
585
+ type: "ExpressionStatement";
586
+ expression: StringLiteral;
587
+ directive: string;
588
+ }
589
+
590
+ interface BlockStatement extends BaseNode {
591
+ type: "BlockStatement";
592
+ body: (Statement | Directive)[];
593
+ }
594
+
595
+ interface IfStatement extends BaseNode {
596
+ type: "IfStatement";
597
+ test: Expression;
598
+ consequent: Statement;
599
+ alternate: Statement | null;
600
+ }
601
+
602
+ interface SwitchStatement extends BaseNode {
603
+ type: "SwitchStatement";
604
+ discriminant: Expression;
605
+ cases: SwitchCase[];
606
+ }
607
+
608
+ interface SwitchCase extends BaseNode {
609
+ type: "SwitchCase";
610
+ test: Expression | null;
611
+ consequent: Statement[];
612
+ }
613
+
614
+ type ForStatementInit = VariableDeclaration | Expression;
615
+ type ForStatementLeft = VariableDeclaration | AssignmentTarget;
616
+
617
+ interface ForStatement extends BaseNode {
618
+ type: "ForStatement";
619
+ init: ForStatementInit | null;
620
+ test: Expression | null;
621
+ update: Expression | null;
622
+ body: Statement;
623
+ }
624
+
625
+ interface ForInStatement extends BaseNode {
626
+ type: "ForInStatement";
627
+ left: ForStatementLeft;
628
+ right: Expression;
629
+ body: Statement;
630
+ }
631
+
632
+ interface ForOfStatement extends BaseNode {
633
+ type: "ForOfStatement";
634
+ left: ForStatementLeft;
635
+ right: Expression;
636
+ body: Statement;
637
+ await: boolean;
638
+ }
639
+
640
+ interface WhileStatement extends BaseNode {
641
+ type: "WhileStatement";
642
+ test: Expression;
643
+ body: Statement;
644
+ }
645
+
646
+ interface DoWhileStatement extends BaseNode {
647
+ type: "DoWhileStatement";
648
+ body: Statement;
649
+ test: Expression;
650
+ }
651
+
652
+ interface BreakStatement extends BaseNode {
653
+ type: "BreakStatement";
654
+ label: LabelIdentifier | null;
655
+ }
656
+
657
+ interface ContinueStatement extends BaseNode {
658
+ type: "ContinueStatement";
659
+ label: LabelIdentifier | null;
660
+ }
661
+
662
+ interface LabeledStatement extends BaseNode {
663
+ type: "LabeledStatement";
664
+ label: LabelIdentifier;
665
+ body: Statement;
666
+ }
667
+
668
+ interface WithStatement extends BaseNode {
669
+ type: "WithStatement";
670
+ object: Expression;
671
+ body: Statement;
672
+ }
673
+
674
+ interface ReturnStatement extends BaseNode {
675
+ type: "ReturnStatement";
676
+ argument: Expression | null;
677
+ }
678
+
679
+ interface ThrowStatement extends BaseNode {
680
+ type: "ThrowStatement";
681
+ argument: Expression;
682
+ }
683
+
684
+ interface TryStatement extends BaseNode {
685
+ type: "TryStatement";
686
+ block: BlockStatement;
687
+ handler: CatchClause | null;
688
+ finalizer: BlockStatement | null;
689
+ }
690
+
691
+ interface CatchClause extends BaseNode {
692
+ type: "CatchClause";
693
+ param: BindingPattern | null;
694
+ body: BlockStatement;
695
+ }
696
+
697
+ interface DebuggerStatement extends BaseNode {
698
+ type: "DebuggerStatement";
699
+ }
700
+
701
+ interface EmptyStatement extends BaseNode {
702
+ type: "EmptyStatement";
703
+ }
704
+
705
+ interface VariableDeclaration extends BaseNode {
706
+ type: "VariableDeclaration";
707
+ kind: VariableDeclarationKind;
708
+ declarations: VariableDeclarator[];
709
+ declare?: boolean;
710
+ }
711
+
712
+ interface VariableDeclarator extends BaseNode {
713
+ type: "VariableDeclarator";
714
+ id: BindingPattern;
715
+ init: Expression | null;
716
+ definite?: boolean;
717
+ }
718
+
719
+ interface FunctionDeclaration extends BaseNode {
720
+ type: "FunctionDeclaration";
721
+ id: BindingIdentifier | null;
722
+ generator: boolean;
723
+ async: boolean;
724
+ params: FunctionParameter[];
725
+ body: BlockStatement | null;
726
+ expression: false;
727
+ declare?: boolean;
728
+ typeParameters?: TSTypeParameterDeclaration | null;
729
+ returnType?: TSTypeAnnotation | null;
730
+ }
731
+
732
+ interface FunctionExpression extends BaseNode {
733
+ type: "FunctionExpression";
734
+ id: BindingIdentifier | null;
735
+ generator: boolean;
736
+ async: boolean;
737
+ params: FunctionParameter[];
738
+ body: BlockStatement | null;
739
+ expression: false;
740
+ declare?: boolean;
741
+ typeParameters?: TSTypeParameterDeclaration | null;
742
+ returnType?: TSTypeAnnotation | null;
743
+ }
744
+
745
+ interface TSDeclareFunction extends BaseNode {
746
+ type: "TSDeclareFunction";
747
+ id: BindingIdentifier | null;
748
+ generator: boolean;
749
+ async: boolean;
750
+ params: FunctionParameter[];
751
+ body: null;
752
+ expression: false;
753
+ declare: boolean;
754
+ typeParameters: TSTypeParameterDeclaration | null;
755
+ returnType: TSTypeAnnotation | null;
756
+ }
757
+
758
+ interface TSEmptyBodyFunctionExpression extends BaseNode {
759
+ type: "TSEmptyBodyFunctionExpression";
760
+ id: BindingIdentifier | null;
761
+ generator: boolean;
762
+ async: boolean;
763
+ params: FunctionParameter[];
764
+ body: null;
765
+ expression: false;
766
+ declare: boolean;
767
+ typeParameters: TSTypeParameterDeclaration | null;
768
+ returnType: TSTypeAnnotation | null;
769
+ }
770
+
771
+ type Function =
772
+ | FunctionDeclaration
773
+ | FunctionExpression
774
+ | TSDeclareFunction
775
+ | TSEmptyBodyFunctionExpression;
776
+
777
+ interface ArrowFunctionExpression extends BaseNode {
778
+ type: "ArrowFunctionExpression";
779
+ id: null;
780
+ generator: false;
781
+ async: boolean;
782
+ params: FunctionParameter[];
783
+ body: BlockStatement | Expression;
784
+ expression: boolean;
785
+ typeParameters?: TSTypeParameterDeclaration | null;
786
+ returnType?: TSTypeAnnotation | null;
787
+ }
788
+
789
+ interface ClassDeclaration extends BaseNode {
790
+ type: "ClassDeclaration";
791
+ decorators: Decorator[];
792
+ id: BindingIdentifier | null;
793
+ superClass: Expression | null;
794
+ body: ClassBody;
795
+ typeParameters?: TSTypeParameterDeclaration | null;
796
+ superTypeArguments?: TSTypeParameterInstantiation | null;
797
+ implements?: TSClassImplements[];
798
+ abstract?: boolean;
799
+ declare?: boolean;
800
+ }
801
+
802
+ interface ClassExpression extends BaseNode {
803
+ type: "ClassExpression";
804
+ decorators: Decorator[];
805
+ id: BindingIdentifier | null;
806
+ superClass: Expression | null;
807
+ body: ClassBody;
808
+ typeParameters?: TSTypeParameterDeclaration | null;
809
+ superTypeArguments?: TSTypeParameterInstantiation | null;
810
+ implements?: TSClassImplements[];
811
+ abstract?: boolean;
812
+ declare?: boolean;
813
+ }
814
+
815
+ type Class = ClassDeclaration | ClassExpression;
816
+
817
+ interface ClassBody extends BaseNode {
818
+ type: "ClassBody";
819
+ body: ClassElement[];
820
+ }
821
+
822
+ interface MethodDefinition extends BaseNode {
823
+ type: "MethodDefinition";
824
+ decorators: Decorator[];
825
+ key: PropertyKey;
826
+ value: FunctionExpression | TSEmptyBodyFunctionExpression;
827
+ kind: MethodDefinitionKind;
828
+ computed: boolean;
829
+ static: boolean;
830
+ override?: boolean;
831
+ optional?: boolean;
832
+ accessibility?: TSAccessibility | null;
833
+ }
834
+
835
+ interface TSAbstractMethodDefinition extends BaseNode {
836
+ type: "TSAbstractMethodDefinition";
837
+ decorators: Decorator[];
838
+ key: PropertyKey;
839
+ value: FunctionExpression | TSEmptyBodyFunctionExpression;
840
+ kind: MethodDefinitionKind;
841
+ computed: boolean;
842
+ static: boolean;
843
+ override?: boolean;
844
+ optional?: boolean;
845
+ accessibility?: TSAccessibility | null;
846
+ }
847
+
848
+ interface PropertyDefinition extends BaseNode {
849
+ type: "PropertyDefinition";
850
+ decorators: Decorator[];
851
+ key: PropertyKey;
852
+ value: Expression | null;
853
+ computed: boolean;
854
+ static: boolean;
855
+ typeAnnotation?: TSTypeAnnotation | null;
856
+ declare?: boolean;
857
+ override?: boolean;
858
+ optional?: boolean;
859
+ definite?: boolean;
860
+ readonly?: boolean;
861
+ accessibility?: TSAccessibility | null;
862
+ }
863
+
864
+ interface TSAbstractPropertyDefinition extends BaseNode {
865
+ type: "TSAbstractPropertyDefinition";
866
+ decorators: Decorator[];
867
+ key: PropertyKey;
868
+ value: Expression | null;
869
+ computed: boolean;
870
+ static: boolean;
871
+ typeAnnotation?: TSTypeAnnotation | null;
872
+ declare?: boolean;
873
+ override?: boolean;
874
+ optional?: boolean;
875
+ definite?: boolean;
876
+ readonly?: boolean;
877
+ accessibility?: TSAccessibility | null;
878
+ }
879
+
880
+ interface AccessorProperty extends BaseNode {
881
+ type: "AccessorProperty";
882
+ decorators: Decorator[];
883
+ key: PropertyKey;
884
+ value: Expression | null;
885
+ computed: boolean;
886
+ static: boolean;
887
+ typeAnnotation?: TSTypeAnnotation | null;
888
+ declare?: boolean;
889
+ override?: boolean;
890
+ optional?: boolean;
891
+ definite?: boolean;
892
+ readonly?: boolean;
893
+ accessibility?: TSAccessibility | null;
894
+ }
895
+
896
+ interface TSAbstractAccessorProperty extends BaseNode {
897
+ type: "TSAbstractAccessorProperty";
898
+ decorators: Decorator[];
899
+ key: PropertyKey;
900
+ value: Expression | null;
901
+ computed: boolean;
902
+ static: boolean;
903
+ typeAnnotation?: TSTypeAnnotation | null;
904
+ declare?: boolean;
905
+ override?: boolean;
906
+ optional?: boolean;
907
+ definite?: boolean;
908
+ readonly?: boolean;
909
+ accessibility?: TSAccessibility | null;
910
+ }
911
+
912
+ interface StaticBlock extends BaseNode {
913
+ type: "StaticBlock";
914
+ body: Statement[];
915
+ }
916
+
917
+ interface Decorator extends BaseNode {
918
+ type: "Decorator";
919
+ expression: Expression;
920
+ }
921
+
922
+ type ClassElement =
923
+ | MethodDefinition
924
+ | TSAbstractMethodDefinition
925
+ | PropertyDefinition
926
+ | TSAbstractPropertyDefinition
927
+ | AccessorProperty
928
+ | TSAbstractAccessorProperty
929
+ | StaticBlock
930
+ | TSIndexSignature;
931
+
932
+ interface ImportDeclaration extends BaseNode {
933
+ type: "ImportDeclaration";
934
+ specifiers: ImportDeclarationSpecifier[];
935
+ source: StringLiteral;
936
+ phase: ImportPhase | null;
937
+ attributes: ImportAttribute[];
938
+ importKind?: ImportOrExportKind;
939
+ }
940
+
941
+ type ImportDeclarationSpecifier =
942
+ | ImportSpecifier
943
+ | ImportDefaultSpecifier
944
+ | ImportNamespaceSpecifier;
945
+
946
+ interface ImportSpecifier extends BaseNode {
947
+ type: "ImportSpecifier";
948
+ imported: IdentifierName | StringLiteral;
949
+ local: BindingIdentifier;
950
+ importKind?: ImportOrExportKind;
951
+ }
952
+
953
+ interface ImportDefaultSpecifier extends BaseNode {
954
+ type: "ImportDefaultSpecifier";
955
+ local: BindingIdentifier;
956
+ }
957
+
958
+ interface ImportNamespaceSpecifier extends BaseNode {
959
+ type: "ImportNamespaceSpecifier";
960
+ local: BindingIdentifier;
961
+ }
962
+
963
+ interface ImportAttribute extends BaseNode {
964
+ type: "ImportAttribute";
965
+ key: ImportAttributeKey;
966
+ value: StringLiteral;
967
+ }
968
+
969
+ type ImportAttributeKey = IdentifierName | StringLiteral;
970
+
971
+ interface ExportNamedDeclaration extends BaseNode {
972
+ type: "ExportNamedDeclaration";
973
+ declaration: Declaration | null;
974
+ specifiers: ExportSpecifier[];
975
+ source: StringLiteral | null;
976
+ attributes: ImportAttribute[];
977
+ exportKind?: ImportOrExportKind;
978
+ }
979
+
980
+ interface ExportDefaultDeclaration extends BaseNode {
981
+ type: "ExportDefaultDeclaration";
982
+ declaration: ExportDefaultDeclarationKind;
983
+ exportKind?: "value";
984
+ }
985
+
986
+ type ExportDefaultDeclarationKind = Function | Class | TSInterfaceDeclaration | Expression;
987
+
988
+ interface ExportAllDeclaration extends BaseNode {
989
+ type: "ExportAllDeclaration";
990
+ exported: ModuleExportName | null;
991
+ source: StringLiteral;
992
+ attributes: ImportAttribute[];
993
+ exportKind?: ImportOrExportKind;
994
+ }
995
+
996
+ interface ExportSpecifier extends BaseNode {
997
+ type: "ExportSpecifier";
998
+ local: ModuleExportName;
999
+ exported: ModuleExportName;
1000
+ exportKind?: ImportOrExportKind;
1001
+ }
1002
+
1003
+ type ModuleExportName = IdentifierName | IdentifierReference | StringLiteral;
1004
+
1005
+ interface JSXElement extends BaseNode {
1006
+ type: "JSXElement";
1007
+ openingElement: JSXOpeningElement;
1008
+ children: JSXChild[];
1009
+ closingElement: JSXClosingElement | null;
1010
+ }
1011
+
1012
+ interface JSXOpeningElement extends BaseNode {
1013
+ type: "JSXOpeningElement";
1014
+ name: JSXElementName;
1015
+ attributes: JSXAttributeItem[];
1016
+ selfClosing: boolean;
1017
+ typeArguments?: TSTypeParameterInstantiation | null;
1018
+ }
1019
+
1020
+ interface JSXClosingElement extends BaseNode {
1021
+ type: "JSXClosingElement";
1022
+ name: JSXElementName;
1023
+ }
1024
+
1025
+ type JSXAttributeItem = JSXAttribute | JSXSpreadAttribute;
1026
+
1027
+ interface JSXFragment extends BaseNode {
1028
+ type: "JSXFragment";
1029
+ openingFragment: JSXOpeningFragment;
1030
+ children: JSXChild[];
1031
+ closingFragment: JSXClosingFragment;
1032
+ }
1033
+
1034
+ interface JSXOpeningFragment extends BaseNode {
1035
+ type: "JSXOpeningFragment";
1036
+ }
1037
+
1038
+ interface JSXClosingFragment extends BaseNode {
1039
+ type: "JSXClosingFragment";
1040
+ }
1041
+
1042
+ interface JSXIdentifier extends BaseNode {
1043
+ type: "JSXIdentifier";
1044
+ name: string;
1045
+ }
1046
+
1047
+ interface JSXNamespacedName extends BaseNode {
1048
+ type: "JSXNamespacedName";
1049
+ namespace: JSXIdentifier;
1050
+ name: JSXIdentifier;
1051
+ }
1052
+
1053
+ interface JSXMemberExpression extends BaseNode {
1054
+ type: "JSXMemberExpression";
1055
+ object: JSXMemberExpressionObject;
1056
+ property: JSXIdentifier;
1057
+ }
1058
+
1059
+ type JSXMemberExpressionObject = JSXIdentifier | JSXMemberExpression;
1060
+
1061
+ interface JSXAttribute extends BaseNode {
1062
+ type: "JSXAttribute";
1063
+ name: JSXAttributeName;
1064
+ value: JSXAttributeValue | null;
1065
+ }
1066
+
1067
+ type JSXAttributeName = JSXIdentifier | JSXNamespacedName;
1068
+
1069
+ type JSXAttributeValue = StringLiteral | JSXExpressionContainer | JSXElement | JSXFragment;
1070
+
1071
+ interface JSXSpreadAttribute extends BaseNode {
1072
+ type: "JSXSpreadAttribute";
1073
+ argument: Expression;
1074
+ }
1075
+
1076
+ interface JSXExpressionContainer extends BaseNode {
1077
+ type: "JSXExpressionContainer";
1078
+ expression: JSXExpression;
1079
+ }
1080
+
1081
+ type JSXExpression = JSXEmptyExpression | Expression;
1082
+
1083
+ interface JSXEmptyExpression extends BaseNode {
1084
+ type: "JSXEmptyExpression";
1085
+ }
1086
+
1087
+ interface JSXText extends BaseNode {
1088
+ type: "JSXText";
1089
+ value: string;
1090
+ raw: string;
1091
+ }
1092
+
1093
+ interface JSXSpreadChild extends BaseNode {
1094
+ type: "JSXSpreadChild";
1095
+ expression: Expression;
1096
+ }
1097
+
1098
+ type JSXElementName = JSXIdentifier | JSXNamespacedName | JSXMemberExpression;
1099
+
1100
+ type JSXTagName = JSXElementName;
1101
+
1102
+ type JSXChild = JSXText | JSXElement | JSXFragment | JSXExpressionContainer | JSXSpreadChild;
1103
+
1104
+ // TypeScript types
1105
+
1106
+ interface TSTypeAnnotation extends BaseNode {
1107
+ type: "TSTypeAnnotation";
1108
+ typeAnnotation: TSType;
1109
+ }
1110
+
1111
+ interface TSAnyKeyword extends BaseNode {
1112
+ type: "TSAnyKeyword";
1113
+ }
1114
+
1115
+ interface TSUnknownKeyword extends BaseNode {
1116
+ type: "TSUnknownKeyword";
1117
+ }
1118
+
1119
+ interface TSNeverKeyword extends BaseNode {
1120
+ type: "TSNeverKeyword";
1121
+ }
1122
+
1123
+ interface TSVoidKeyword extends BaseNode {
1124
+ type: "TSVoidKeyword";
1125
+ }
1126
+
1127
+ interface TSNullKeyword extends BaseNode {
1128
+ type: "TSNullKeyword";
1129
+ }
1130
+
1131
+ interface TSUndefinedKeyword extends BaseNode {
1132
+ type: "TSUndefinedKeyword";
1133
+ }
1134
+
1135
+ interface TSStringKeyword extends BaseNode {
1136
+ type: "TSStringKeyword";
1137
+ }
1138
+
1139
+ interface TSNumberKeyword extends BaseNode {
1140
+ type: "TSNumberKeyword";
1141
+ }
1142
+
1143
+ interface TSBigIntKeyword extends BaseNode {
1144
+ type: "TSBigIntKeyword";
1145
+ }
1146
+
1147
+ interface TSBooleanKeyword extends BaseNode {
1148
+ type: "TSBooleanKeyword";
1149
+ }
1150
+
1151
+ interface TSSymbolKeyword extends BaseNode {
1152
+ type: "TSSymbolKeyword";
1153
+ }
1154
+
1155
+ interface TSObjectKeyword extends BaseNode {
1156
+ type: "TSObjectKeyword";
1157
+ }
1158
+
1159
+ interface TSIntrinsicKeyword extends BaseNode {
1160
+ type: "TSIntrinsicKeyword";
1161
+ }
1162
+
1163
+ interface TSThisType extends BaseNode {
1164
+ type: "TSThisType";
1165
+ }
1166
+
1167
+ interface TSTypeReference extends BaseNode {
1168
+ type: "TSTypeReference";
1169
+ typeName: TSTypeName;
1170
+ typeArguments: TSTypeParameterInstantiation | null;
1171
+ }
1172
+
1173
+ interface TSQualifiedName extends BaseNode {
1174
+ type: "TSQualifiedName";
1175
+ left: TSTypeName;
1176
+ right: IdentifierName;
1177
+ }
1178
+
1179
+ type TSTypeName = IdentifierReference | TSQualifiedName | ThisExpression;
1180
+
1181
+ interface TSTypeQuery extends BaseNode {
1182
+ type: "TSTypeQuery";
1183
+ exprName: TSTypeQueryExprName;
1184
+ typeArguments: TSTypeParameterInstantiation | null;
1185
+ }
1186
+
1187
+ type TSTypeQueryExprName = IdentifierReference | TSQualifiedName | TSImportType;
1188
+
1189
+ interface TSImportType extends BaseNode {
1190
+ type: "TSImportType";
1191
+ source: StringLiteral;
1192
+ options: ObjectExpression | null;
1193
+ qualifier: TSImportTypeQualifier | null;
1194
+ typeArguments: TSTypeParameterInstantiation | null;
1195
+ }
1196
+
1197
+ type TSImportTypeQualifier = IdentifierName | TSQualifiedName;
1198
+
1199
+ interface TSTypeParameter extends BaseNode {
1200
+ type: "TSTypeParameter";
1201
+ name: BindingIdentifier;
1202
+ constraint: TSType | null;
1203
+ default: TSType | null;
1204
+ in: boolean;
1205
+ out: boolean;
1206
+ const: boolean;
1207
+ }
1208
+
1209
+ interface TSTypeParameterDeclaration extends BaseNode {
1210
+ type: "TSTypeParameterDeclaration";
1211
+ params: TSTypeParameter[];
1212
+ }
1213
+
1214
+ interface TSTypeParameterInstantiation extends BaseNode {
1215
+ type: "TSTypeParameterInstantiation";
1216
+ params: TSType[];
1217
+ }
1218
+
1219
+ interface TSLiteralType extends BaseNode {
1220
+ type: "TSLiteralType";
1221
+ literal:
1222
+ | StringLiteral
1223
+ | NumericLiteral
1224
+ | BigIntLiteral
1225
+ | BooleanLiteral
1226
+ | TemplateLiteral
1227
+ | UnaryExpression;
1228
+ }
1229
+
1230
+ interface TSTemplateLiteralType extends BaseNode {
1231
+ type: "TSTemplateLiteralType";
1232
+ quasis: TemplateElement[];
1233
+ types: TSType[];
1234
+ }
1235
+
1236
+ interface TSArrayType extends BaseNode {
1237
+ type: "TSArrayType";
1238
+ elementType: TSType;
1239
+ }
1240
+
1241
+ interface TSIndexedAccessType extends BaseNode {
1242
+ type: "TSIndexedAccessType";
1243
+ objectType: TSType;
1244
+ indexType: TSType;
1245
+ }
1246
+
1247
+ interface TSTupleType extends BaseNode {
1248
+ type: "TSTupleType";
1249
+ elementTypes: TSTupleElement[];
1250
+ }
1251
+
1252
+ interface TSNamedTupleMember extends BaseNode {
1253
+ type: "TSNamedTupleMember";
1254
+ label: IdentifierName;
1255
+ elementType: TSType;
1256
+ optional: boolean;
1257
+ }
1258
+
1259
+ interface TSOptionalType extends BaseNode {
1260
+ type: "TSOptionalType";
1261
+ typeAnnotation: TSType;
1262
+ }
1263
+
1264
+ interface TSRestType extends BaseNode {
1265
+ type: "TSRestType";
1266
+ typeAnnotation: TSType | TSNamedTupleMember;
1267
+ }
1268
+
1269
+ type TSTupleElement = TSType | TSNamedTupleMember | TSOptionalType | TSRestType;
1270
+
1271
+ interface TSJSDocNullableType extends BaseNode {
1272
+ type: "TSJSDocNullableType";
1273
+ typeAnnotation: TSType;
1274
+ postfix: boolean;
1275
+ }
1276
+
1277
+ interface TSJSDocNonNullableType extends BaseNode {
1278
+ type: "TSJSDocNonNullableType";
1279
+ typeAnnotation: TSType;
1280
+ postfix: boolean;
1281
+ }
1282
+
1283
+ interface TSJSDocUnknownType extends BaseNode {
1284
+ type: "TSJSDocUnknownType";
1285
+ }
1286
+
1287
+ interface TSUnionType extends BaseNode {
1288
+ type: "TSUnionType";
1289
+ types: TSType[];
1290
+ }
1291
+
1292
+ interface TSIntersectionType extends BaseNode {
1293
+ type: "TSIntersectionType";
1294
+ types: TSType[];
1295
+ }
1296
+
1297
+ interface TSConditionalType extends BaseNode {
1298
+ type: "TSConditionalType";
1299
+ checkType: TSType;
1300
+ extendsType: TSType;
1301
+ trueType: TSType;
1302
+ falseType: TSType;
1303
+ }
1304
+
1305
+ interface TSInferType extends BaseNode {
1306
+ type: "TSInferType";
1307
+ typeParameter: TSTypeParameter;
1308
+ }
1309
+
1310
+ interface TSTypeOperator extends BaseNode {
1311
+ type: "TSTypeOperator";
1312
+ operator: TSTypeOperatorOperator;
1313
+ typeAnnotation: TSType;
1314
+ }
1315
+
1316
+ interface TSParenthesizedType extends BaseNode {
1317
+ type: "TSParenthesizedType";
1318
+ typeAnnotation: TSType;
1319
+ }
1320
+
1321
+ interface TSFunctionType extends BaseNode {
1322
+ type: "TSFunctionType";
1323
+ typeParameters: TSTypeParameterDeclaration | null;
1324
+ params: FunctionParameter[];
1325
+ returnType: TSTypeAnnotation | null;
1326
+ }
1327
+
1328
+ interface TSConstructorType extends BaseNode {
1329
+ type: "TSConstructorType";
1330
+ abstract: boolean;
1331
+ typeParameters: TSTypeParameterDeclaration | null;
1332
+ params: FunctionParameter[];
1333
+ returnType: TSTypeAnnotation | null;
1334
+ }
1335
+
1336
+ interface TSTypePredicate extends BaseNode {
1337
+ type: "TSTypePredicate";
1338
+ parameterName: TSTypePredicateName;
1339
+ typeAnnotation: TSTypeAnnotation | null;
1340
+ asserts: boolean;
1341
+ }
1342
+
1343
+ type TSTypePredicateName = IdentifierName | TSThisType;
1344
+
1345
+ interface TSTypeLiteral extends BaseNode {
1346
+ type: "TSTypeLiteral";
1347
+ members: TSSignature[];
1348
+ }
1349
+
1350
+ interface TSMappedType extends BaseNode {
1351
+ type: "TSMappedType";
1352
+ key: BindingIdentifier;
1353
+ constraint: TSType;
1354
+ nameType: TSType | null;
1355
+ typeAnnotation: TSType | null;
1356
+ optional: TSMappedTypeModifierOperator | false;
1357
+ readonly: TSMappedTypeModifierOperator | null;
1358
+ }
1359
+
1360
+ interface TSPropertySignature extends BaseNode {
1361
+ type: "TSPropertySignature";
1362
+ key: PropertyKey;
1363
+ typeAnnotation: TSTypeAnnotation | null;
1364
+ computed: boolean;
1365
+ optional: boolean;
1366
+ readonly: boolean;
1367
+ accessibility: null;
1368
+ static: false;
1369
+ }
1370
+
1371
+ interface TSMethodSignature extends BaseNode {
1372
+ type: "TSMethodSignature";
1373
+ key: PropertyKey;
1374
+ computed: boolean;
1375
+ optional: boolean;
1376
+ kind: TSMethodSignatureKind;
1377
+ typeParameters: TSTypeParameterDeclaration | null;
1378
+ params: FunctionParameter[];
1379
+ returnType: TSTypeAnnotation | null;
1380
+ accessibility: null;
1381
+ readonly: false;
1382
+ static: false;
1383
+ }
1384
+
1385
+ interface TSCallSignatureDeclaration extends BaseNode {
1386
+ type: "TSCallSignatureDeclaration";
1387
+ typeParameters: TSTypeParameterDeclaration | null;
1388
+ params: FunctionParameter[];
1389
+ returnType: TSTypeAnnotation | null;
1390
+ }
1391
+
1392
+ interface TSConstructSignatureDeclaration extends BaseNode {
1393
+ type: "TSConstructSignatureDeclaration";
1394
+ typeParameters: TSTypeParameterDeclaration | null;
1395
+ params: FunctionParameter[];
1396
+ returnType: TSTypeAnnotation | null;
1397
+ }
1398
+
1399
+ interface TSIndexSignature extends BaseNode {
1400
+ type: "TSIndexSignature";
1401
+ parameters: BindingIdentifier[];
1402
+ typeAnnotation: TSTypeAnnotation;
1403
+ readonly: boolean;
1404
+ static: boolean;
1405
+ accessibility: null;
1406
+ }
1407
+
1408
+ type TSSignature =
1409
+ | TSPropertySignature
1410
+ | TSMethodSignature
1411
+ | TSCallSignatureDeclaration
1412
+ | TSConstructSignatureDeclaration
1413
+ | TSIndexSignature;
1414
+
1415
+ interface TSTypeAliasDeclaration extends BaseNode {
1416
+ type: "TSTypeAliasDeclaration";
1417
+ id: BindingIdentifier;
1418
+ typeParameters: TSTypeParameterDeclaration | null;
1419
+ typeAnnotation: TSType;
1420
+ declare: boolean;
1421
+ }
1422
+
1423
+ interface TSInterfaceDeclaration extends BaseNode {
1424
+ type: "TSInterfaceDeclaration";
1425
+ id: BindingIdentifier;
1426
+ typeParameters: TSTypeParameterDeclaration | null;
1427
+ extends: TSInterfaceHeritage[];
1428
+ body: TSInterfaceBody;
1429
+ declare: boolean;
1430
+ }
1431
+
1432
+ interface TSInterfaceBody extends BaseNode {
1433
+ type: "TSInterfaceBody";
1434
+ body: TSSignature[];
1435
+ }
1436
+
1437
+ interface TSInterfaceHeritage extends BaseNode {
1438
+ type: "TSInterfaceHeritage";
1439
+ expression: Expression;
1440
+ typeArguments: TSTypeParameterInstantiation | null;
1441
+ }
1442
+
1443
+ interface TSClassImplements extends BaseNode {
1444
+ type: "TSClassImplements";
1445
+ expression: Expression;
1446
+ typeArguments: TSTypeParameterInstantiation | null;
1447
+ }
1448
+
1449
+ interface TSEnumDeclaration extends BaseNode {
1450
+ type: "TSEnumDeclaration";
1451
+ id: BindingIdentifier;
1452
+ body: TSEnumBody;
1453
+ const: boolean;
1454
+ declare: boolean;
1455
+ }
1456
+
1457
+ interface TSEnumBody extends BaseNode {
1458
+ type: "TSEnumBody";
1459
+ members: TSEnumMember[];
1460
+ }
1461
+
1462
+ interface TSEnumMember extends BaseNode {
1463
+ type: "TSEnumMember";
1464
+ id: TSEnumMemberName;
1465
+ initializer: Expression | null;
1466
+ computed: boolean;
1467
+ }
1468
+
1469
+ type TSEnumMemberName = IdentifierName | StringLiteral | TemplateLiteral;
1470
+
1471
+ interface TSModuleDeclaration extends BaseNode {
1472
+ type: "TSModuleDeclaration";
1473
+ id: BindingIdentifier | StringLiteral | TSQualifiedName | IdentifierName;
1474
+ body?: TSModuleBlock;
1475
+ kind: TSModuleDeclarationKind;
1476
+ declare: boolean;
1477
+ global: boolean;
1478
+ }
1479
+
1480
+ interface TSModuleBlock extends BaseNode {
1481
+ type: "TSModuleBlock";
1482
+ body: ProgramStatement[];
1483
+ }
1484
+
1485
+ interface TSParameterProperty extends BaseNode {
1486
+ type: "TSParameterProperty";
1487
+ decorators: Decorator[];
1488
+ parameter: BindingIdentifier | AssignmentPattern;
1489
+ override: boolean;
1490
+ readonly: boolean;
1491
+ accessibility: TSAccessibility | null;
1492
+ static: false;
1493
+ }
1494
+
1495
+ interface TSAsExpression extends BaseNode {
1496
+ type: "TSAsExpression";
1497
+ expression: Expression;
1498
+ typeAnnotation: TSType;
1499
+ }
1500
+
1501
+ interface TSSatisfiesExpression extends BaseNode {
1502
+ type: "TSSatisfiesExpression";
1503
+ expression: Expression;
1504
+ typeAnnotation: TSType;
1505
+ }
1506
+
1507
+ interface TSTypeAssertion extends BaseNode {
1508
+ type: "TSTypeAssertion";
1509
+ typeAnnotation: TSType;
1510
+ expression: Expression;
1511
+ }
1512
+
1513
+ interface TSNonNullExpression extends BaseNode {
1514
+ type: "TSNonNullExpression";
1515
+ expression: Expression;
1516
+ }
1517
+
1518
+ interface TSInstantiationExpression extends BaseNode {
1519
+ type: "TSInstantiationExpression";
1520
+ expression: Expression;
1521
+ typeArguments: TSTypeParameterInstantiation;
1522
+ }
1523
+
1524
+ interface TSExportAssignment extends BaseNode {
1525
+ type: "TSExportAssignment";
1526
+ expression: Expression;
1527
+ }
1528
+
1529
+ interface TSNamespaceExportDeclaration extends BaseNode {
1530
+ type: "TSNamespaceExportDeclaration";
1531
+ id: IdentifierName;
1532
+ }
1533
+
1534
+ interface TSImportEqualsDeclaration extends BaseNode {
1535
+ type: "TSImportEqualsDeclaration";
1536
+ id: BindingIdentifier;
1537
+ moduleReference: TSModuleReference;
1538
+ importKind: ImportOrExportKind;
1539
+ }
1540
+
1541
+ type TSModuleReference = TSExternalModuleReference | IdentifierReference | TSQualifiedName;
1542
+
1543
+ interface TSExternalModuleReference extends BaseNode {
1544
+ type: "TSExternalModuleReference";
1545
+ expression: StringLiteral;
1546
+ }
1547
+
1548
+ type TSType =
1549
+ | TSAnyKeyword
1550
+ | TSUnknownKeyword
1551
+ | TSNeverKeyword
1552
+ | TSVoidKeyword
1553
+ | TSNullKeyword
1554
+ | TSUndefinedKeyword
1555
+ | TSStringKeyword
1556
+ | TSNumberKeyword
1557
+ | TSBigIntKeyword
1558
+ | TSBooleanKeyword
1559
+ | TSSymbolKeyword
1560
+ | TSObjectKeyword
1561
+ | TSIntrinsicKeyword
1562
+ | TSThisType
1563
+ | TSTypeReference
1564
+ | TSTypeQuery
1565
+ | TSImportType
1566
+ | TSLiteralType
1567
+ | TSTemplateLiteralType
1568
+ | TSArrayType
1569
+ | TSIndexedAccessType
1570
+ | TSTupleType
1571
+ | TSNamedTupleMember
1572
+ | TSJSDocNullableType
1573
+ | TSJSDocNonNullableType
1574
+ | TSJSDocUnknownType
1575
+ | TSUnionType
1576
+ | TSIntersectionType
1577
+ | TSConditionalType
1578
+ | TSInferType
1579
+ | TSTypeOperator
1580
+ | TSParenthesizedType
1581
+ | TSFunctionType
1582
+ | TSConstructorType
1583
+ | TSTypePredicate
1584
+ | TSTypeLiteral
1585
+ | TSMappedType;
1586
+
1587
+ interface Hashbang extends BaseNode {
1588
+ type: "Hashbang";
1589
+ value: string;
1590
+ }
1591
+
1592
+ interface Program extends BaseNode {
1593
+ type: "Program";
1594
+ sourceType: ModuleKind;
1595
+ hashbang: Hashbang | null;
1596
+ body: ProgramStatement[];
1597
+ }
1598
+
1599
+ /**
1600
+ * An element of `Program.body`. Unlike {@link Statement}, this also includes
1601
+ * {@link ModuleDeclaration} (`import`/`export`) and {@link Directive}, which
1602
+ * are only valid at the top level of a program, never in nested statement
1603
+ * positions such as a block, loop, or `if` body.
1604
+ */
1605
+ type ProgramStatement = Statement | ModuleDeclaration | Directive;
1606
+
1607
+ type Declaration =
1608
+ | FunctionDeclaration
1609
+ | ClassDeclaration
1610
+ | VariableDeclaration
1611
+ | TSDeclareFunction
1612
+ | TSTypeAliasDeclaration
1613
+ | TSInterfaceDeclaration
1614
+ | TSEnumDeclaration
1615
+ | TSModuleDeclaration
1616
+ | TSImportEqualsDeclaration;
1617
+
1618
+ type Expression =
1619
+ | IdentifierReference
1620
+ | Literal
1621
+ | ThisExpression
1622
+ | Super
1623
+ | ArrayExpression
1624
+ | ObjectExpression
1625
+ | FunctionExpression
1626
+ | ArrowFunctionExpression
1627
+ | ClassExpression
1628
+ | TaggedTemplateExpression
1629
+ | TemplateLiteral
1630
+ | MemberExpression
1631
+ | CallExpression
1632
+ | NewExpression
1633
+ | ChainExpression
1634
+ | SequenceExpression
1635
+ | ParenthesizedExpression
1636
+ | BinaryExpression
1637
+ | LogicalExpression
1638
+ | ConditionalExpression
1639
+ | UnaryExpression
1640
+ | UpdateExpression
1641
+ | AssignmentExpression
1642
+ | YieldExpression
1643
+ | AwaitExpression
1644
+ | ImportExpression
1645
+ | MetaProperty
1646
+ | TSAsExpression
1647
+ | TSSatisfiesExpression
1648
+ | TSTypeAssertion
1649
+ | TSNonNullExpression
1650
+ | TSInstantiationExpression
1651
+ | JSXElement
1652
+ | JSXFragment;
1653
+
1654
+ type Statement =
1655
+ | ExpressionStatement
1656
+ | BlockStatement
1657
+ | EmptyStatement
1658
+ | DebuggerStatement
1659
+ | ReturnStatement
1660
+ | LabeledStatement
1661
+ | BreakStatement
1662
+ | ContinueStatement
1663
+ | IfStatement
1664
+ | SwitchStatement
1665
+ | ThrowStatement
1666
+ | TryStatement
1667
+ | WhileStatement
1668
+ | DoWhileStatement
1669
+ | ForStatement
1670
+ | ForInStatement
1671
+ | ForOfStatement
1672
+ | WithStatement
1673
+ | Declaration;
1674
+
1675
+ type ModuleDeclaration =
1676
+ | ImportDeclaration
1677
+ | ExportNamedDeclaration
1678
+ | ExportDefaultDeclaration
1679
+ | ExportAllDeclaration
1680
+ | TSExportAssignment
1681
+ | TSNamespaceExportDeclaration;
1682
+
1683
+ type Node =
1684
+ | Program
1685
+ | Hashbang
1686
+ | Statement
1687
+ | Expression
1688
+ | ModuleDeclaration
1689
+ | Directive
1690
+ | ObjectProperty
1691
+ | BindingProperty
1692
+ | SpreadElement
1693
+ | PrivateIdentifier
1694
+ | TemplateElement
1695
+ | VariableDeclarator
1696
+ | CatchClause
1697
+ | SwitchCase
1698
+ | RestElement
1699
+ | ArrayPattern
1700
+ | ObjectPattern
1701
+ | AssignmentPattern
1702
+ | ClassBody
1703
+ | MethodDefinition
1704
+ | TSAbstractMethodDefinition
1705
+ | PropertyDefinition
1706
+ | TSAbstractPropertyDefinition
1707
+ | AccessorProperty
1708
+ | TSAbstractAccessorProperty
1709
+ | StaticBlock
1710
+ | Decorator
1711
+ | TSEmptyBodyFunctionExpression
1712
+ | ImportSpecifier
1713
+ | ImportDefaultSpecifier
1714
+ | ImportNamespaceSpecifier
1715
+ | ImportAttribute
1716
+ | ExportSpecifier
1717
+ | JSXOpeningElement
1718
+ | JSXClosingElement
1719
+ | JSXOpeningFragment
1720
+ | JSXClosingFragment
1721
+ | JSXIdentifier
1722
+ | JSXNamespacedName
1723
+ | JSXMemberExpression
1724
+ | JSXAttribute
1725
+ | JSXSpreadAttribute
1726
+ | JSXExpressionContainer
1727
+ | JSXEmptyExpression
1728
+ | JSXText
1729
+ | JSXSpreadChild
1730
+ | TSTypeAnnotation
1731
+ | TSType
1732
+ | TSTypeParameter
1733
+ | TSTypeParameterDeclaration
1734
+ | TSTypeParameterInstantiation
1735
+ | TSQualifiedName
1736
+ | TSPropertySignature
1737
+ | TSMethodSignature
1738
+ | TSCallSignatureDeclaration
1739
+ | TSConstructSignatureDeclaration
1740
+ | TSIndexSignature
1741
+ | TSInterfaceBody
1742
+ | TSInterfaceHeritage
1743
+ | TSClassImplements
1744
+ | TSEnumBody
1745
+ | TSEnumMember
1746
+ | TSModuleBlock
1747
+ | TSParameterProperty
1748
+ | TSExternalModuleReference
1749
+ | TSOptionalType
1750
+ | TSRestType;
1751
+
1752
+ export { WalkContext };
1753
+ export type {
1754
+ NodeOfType,
1755
+ NodeType,
1756
+ ScanCursor,
1757
+ Comment,
1758
+ AttachedComment,
1759
+ CommentType,
1760
+ CommentPosition,
1761
+ Diagnostic,
1762
+ DiagnosticLabel,
1763
+ DiagnosticSeverity,
1764
+ SourceType,
1765
+ ModuleKind,
1766
+ SourceLang,
1767
+ SourceLocation,
1768
+ BaseNode,
1769
+ Span,
1770
+ Program,
1771
+ ProgramStatement,
1772
+ Statement,
1773
+ Expression,
1774
+ Declaration,
1775
+ ModuleDeclaration,
1776
+ Node,
1777
+ Hashbang,
1778
+ AssignmentTarget,
1779
+ SimpleAssignmentTarget,
1780
+ AssignmentTargetPattern,
1781
+ Argument,
1782
+ ArrayExpressionElement,
1783
+ ObjectPropertyKind,
1784
+ ForStatementInit,
1785
+ ForStatementLeft,
1786
+ ChainElement,
1787
+ ExportDefaultDeclarationKind,
1788
+ ImportDeclarationSpecifier,
1789
+ ImportAttributeKey,
1790
+ ModuleExportName,
1791
+ PropertyKey,
1792
+ Identifier,
1793
+ IdentifierName,
1794
+ IdentifierReference,
1795
+ BindingIdentifier,
1796
+ LabelIdentifier,
1797
+ PrivateIdentifier,
1798
+ Literal,
1799
+ StringLiteral,
1800
+ NumericLiteral,
1801
+ BigIntLiteral,
1802
+ BooleanLiteral,
1803
+ NullLiteral,
1804
+ RegExpLiteral,
1805
+ BindingPattern,
1806
+ FunctionParameter,
1807
+ Property,
1808
+ ObjectProperty,
1809
+ BindingProperty,
1810
+ ArrayPattern,
1811
+ ObjectPattern,
1812
+ AssignmentPattern,
1813
+ RestElement,
1814
+ SequenceExpression,
1815
+ ParenthesizedExpression,
1816
+ BinaryExpression,
1817
+ LogicalExpression,
1818
+ ConditionalExpression,
1819
+ UnaryExpression,
1820
+ UpdateExpression,
1821
+ AssignmentExpression,
1822
+ YieldExpression,
1823
+ AwaitExpression,
1824
+ ArrayExpression,
1825
+ ObjectExpression,
1826
+ SpreadElement,
1827
+ MemberExpression,
1828
+ ComputedMemberExpression,
1829
+ StaticMemberExpression,
1830
+ PrivateFieldExpression,
1831
+ CallExpression,
1832
+ ChainExpression,
1833
+ TaggedTemplateExpression,
1834
+ NewExpression,
1835
+ MetaProperty,
1836
+ ImportExpression,
1837
+ TemplateLiteral,
1838
+ TemplateElement,
1839
+ Super,
1840
+ ThisExpression,
1841
+ Directive,
1842
+ ExpressionStatement,
1843
+ BlockStatement,
1844
+ IfStatement,
1845
+ SwitchStatement,
1846
+ SwitchCase,
1847
+ ForStatement,
1848
+ ForInStatement,
1849
+ ForOfStatement,
1850
+ WhileStatement,
1851
+ DoWhileStatement,
1852
+ BreakStatement,
1853
+ ContinueStatement,
1854
+ LabeledStatement,
1855
+ WithStatement,
1856
+ ReturnStatement,
1857
+ ThrowStatement,
1858
+ TryStatement,
1859
+ CatchClause,
1860
+ DebuggerStatement,
1861
+ EmptyStatement,
1862
+ VariableDeclaration,
1863
+ VariableDeclarator,
1864
+ VariableDeclarationKind,
1865
+ Function,
1866
+ FunctionDeclaration,
1867
+ FunctionExpression,
1868
+ TSDeclareFunction,
1869
+ TSEmptyBodyFunctionExpression,
1870
+ FunctionType,
1871
+ ArrowFunctionExpression,
1872
+ Class,
1873
+ ClassDeclaration,
1874
+ ClassExpression,
1875
+ ClassType,
1876
+ ClassBody,
1877
+ MethodDefinition,
1878
+ TSAbstractMethodDefinition,
1879
+ MethodDefinitionType,
1880
+ MethodDefinitionKind,
1881
+ PropertyDefinition,
1882
+ TSAbstractPropertyDefinition,
1883
+ PropertyDefinitionType,
1884
+ AccessorProperty,
1885
+ TSAbstractAccessorProperty,
1886
+ AccessorPropertyType,
1887
+ PropertyKind,
1888
+ StaticBlock,
1889
+ Decorator,
1890
+ ClassElement,
1891
+ ImportDeclaration,
1892
+ ImportSpecifier,
1893
+ ImportDefaultSpecifier,
1894
+ ImportNamespaceSpecifier,
1895
+ ImportAttribute,
1896
+ ImportPhase,
1897
+ ImportOrExportKind,
1898
+ ExportNamedDeclaration,
1899
+ ExportDefaultDeclaration,
1900
+ ExportAllDeclaration,
1901
+ ExportSpecifier,
1902
+ JSXElement,
1903
+ JSXOpeningElement,
1904
+ JSXClosingElement,
1905
+ JSXFragment,
1906
+ JSXOpeningFragment,
1907
+ JSXClosingFragment,
1908
+ JSXIdentifier,
1909
+ JSXNamespacedName,
1910
+ JSXMemberExpression,
1911
+ JSXMemberExpressionObject,
1912
+ JSXAttribute,
1913
+ JSXAttributeItem,
1914
+ JSXAttributeName,
1915
+ JSXAttributeValue,
1916
+ JSXSpreadAttribute,
1917
+ JSXExpressionContainer,
1918
+ JSXExpression,
1919
+ JSXEmptyExpression,
1920
+ JSXText,
1921
+ JSXSpreadChild,
1922
+ JSXTagName,
1923
+ JSXElementName,
1924
+ JSXChild,
1925
+ TSType,
1926
+ TSTypeName,
1927
+ TSSignature,
1928
+ TSTupleElement,
1929
+ TSTypeAnnotation,
1930
+ TSAnyKeyword,
1931
+ TSUnknownKeyword,
1932
+ TSNeverKeyword,
1933
+ TSVoidKeyword,
1934
+ TSNullKeyword,
1935
+ TSUndefinedKeyword,
1936
+ TSStringKeyword,
1937
+ TSNumberKeyword,
1938
+ TSBigIntKeyword,
1939
+ TSBooleanKeyword,
1940
+ TSSymbolKeyword,
1941
+ TSObjectKeyword,
1942
+ TSIntrinsicKeyword,
1943
+ TSThisType,
1944
+ TSTypeReference,
1945
+ TSQualifiedName,
1946
+ TSTypeQuery,
1947
+ TSTypeQueryExprName,
1948
+ TSImportType,
1949
+ TSImportTypeQualifier,
1950
+ TSTypeParameter,
1951
+ TSTypeParameterDeclaration,
1952
+ TSTypeParameterInstantiation,
1953
+ TSLiteralType,
1954
+ TSTemplateLiteralType,
1955
+ TSArrayType,
1956
+ TSIndexedAccessType,
1957
+ TSTupleType,
1958
+ TSNamedTupleMember,
1959
+ TSOptionalType,
1960
+ TSRestType,
1961
+ TSJSDocNullableType,
1962
+ TSJSDocNonNullableType,
1963
+ TSJSDocUnknownType,
1964
+ TSUnionType,
1965
+ TSIntersectionType,
1966
+ TSConditionalType,
1967
+ TSInferType,
1968
+ TSTypeOperator,
1969
+ TSTypeOperatorOperator,
1970
+ TSParenthesizedType,
1971
+ TSFunctionType,
1972
+ TSConstructorType,
1973
+ TSTypePredicate,
1974
+ TSTypePredicateName,
1975
+ TSTypeLiteral,
1976
+ TSMappedType,
1977
+ TSMappedTypeModifierOperator,
1978
+ TSPropertySignature,
1979
+ TSMethodSignature,
1980
+ TSMethodSignatureKind,
1981
+ TSCallSignatureDeclaration,
1982
+ TSConstructSignatureDeclaration,
1983
+ TSIndexSignature,
1984
+ TSTypeAliasDeclaration,
1985
+ TSInterfaceDeclaration,
1986
+ TSInterfaceBody,
1987
+ TSInterfaceHeritage,
1988
+ TSClassImplements,
1989
+ TSEnumDeclaration,
1990
+ TSEnumBody,
1991
+ TSEnumMember,
1992
+ TSEnumMemberName,
1993
+ TSModuleDeclaration,
1994
+ TSModuleDeclarationKind,
1995
+ TSModuleBlock,
1996
+ TSParameterProperty,
1997
+ TSAccessibility,
1998
+ TSAsExpression,
1999
+ TSSatisfiesExpression,
2000
+ TSTypeAssertion,
2001
+ TSNonNullExpression,
2002
+ TSInstantiationExpression,
2003
+ TSExportAssignment,
2004
+ TSNamespaceExportDeclaration,
2005
+ TSImportEqualsDeclaration,
2006
+ TSExternalModuleReference,
2007
+ TSModuleReference,
2008
+ BinaryOperator,
2009
+ LogicalOperator,
2010
+ UnaryOperator,
2011
+ UpdateOperator,
2012
+ AssignmentOperator,
2013
+ };