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