yuku-parser 0.4.6 → 0.5.0-beta.2

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