hermes-estree 0.5.0 → 0.8.0

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -64,6 +64,7 @@ export interface MostTokens extends BaseToken {
64
64
  | 'Keyword'
65
65
  | 'Null'
66
66
  | 'Numeric'
67
+ | 'BigInt'
67
68
  | 'Punctuator'
68
69
  | 'RegularExpression'
69
70
  | 'String'
@@ -104,6 +105,26 @@ export interface Position {
104
105
  +column: number;
105
106
  }
106
107
 
108
+ // note: this is only ever present on Program.interpreter, never in the body
109
+ interface InterpreterDirective extends BaseNode {
110
+ type: 'InterpreterDirective';
111
+ value: string;
112
+ }
113
+
114
+ export type DocblockDirectives = $ReadOnly<{
115
+ // some well-known tags
116
+ flow?: $ReadOnlyArray<string> | void,
117
+ format?: $ReadOnlyArray<string> | void,
118
+ noflow?: $ReadOnlyArray<string> | void,
119
+ noformat?: $ReadOnlyArray<string> | void,
120
+ [string]: $ReadOnlyArray<string> | void,
121
+ }>;
122
+
123
+ export type DocblockMetadata = $ReadOnly<{
124
+ directives: DocblockDirectives,
125
+ comment: BlockComment,
126
+ }>;
127
+
107
128
  export interface Program extends BaseNode {
108
129
  +type: 'Program';
109
130
  +sourceType: 'script' | 'module';
@@ -111,6 +132,8 @@ export interface Program extends BaseNode {
111
132
  +tokens: $ReadOnlyArray<Token>;
112
133
  +comments: $ReadOnlyArray<Comment>;
113
134
  +loc: SourceLocation;
135
+ +interpreter: null | InterpreterDirective;
136
+ +docblock: null | DocblockMetadata;
114
137
  // program is the only node without a parent - but typing it as such is _super_ annoying and difficult
115
138
  +parent: ESNode;
116
139
  }
@@ -119,6 +142,7 @@ export interface Program extends BaseNode {
119
142
  // Because this file declares global types - we can't clash with it
120
143
  export type ESNode =
121
144
  | Identifier
145
+ | PrivateIdentifier
122
146
  | Literal
123
147
  | Program
124
148
  | AFunction
@@ -131,10 +155,14 @@ export type ESNode =
131
155
  | Super
132
156
  | TemplateElement
133
157
  | SpreadElement
134
- | Pattern
158
+ | BindingName
159
+ | RestElement
160
+ | AssignmentPattern
161
+ | MemberExpression
135
162
  | ClassBody
136
163
  | AClass
137
164
  | MethodDefinition
165
+ | PropertyDefinition
138
166
  | ModuleDeclaration
139
167
  | ModuleSpecifier
140
168
  | ImportAttribute
@@ -149,8 +177,6 @@ export type ESNode =
149
177
  | ObjectTypeIndexer
150
178
  | ObjectTypeSpreadProperty
151
179
  | InterfaceExtends
152
- | ClassProperty
153
- | ClassPrivateProperty
154
180
  | ClassImplements
155
181
  | Decorator
156
182
  | TypeParameterDeclaration
@@ -165,17 +191,23 @@ export type ESNode =
165
191
  | EnumBooleanBody
166
192
  | EnumBooleanMember
167
193
  | EnumSymbolBody
168
- | DeclareClass
169
- | DeclareVariable
170
- | DeclareFunction
171
- | DeclaredPredicate
172
- | DeclareModule
194
+ | DeclaredNode
173
195
  | ObjectTypeInternalSlot
174
196
  // JSX
175
197
  | JSXNode;
176
198
 
199
+ export type BindingName = Identifier | BindingPattern;
200
+ export type BindingPattern = ArrayPattern | ObjectPattern;
201
+ export type RestElementPattern = AssignmentPattern | BindingName | RestElement;
202
+ export type FunctionParameter = AssignmentPattern | BindingName | RestElement;
203
+ export type DestructuringPattern =
204
+ | BindingName
205
+ | AssignmentPattern
206
+ | MemberExpression
207
+ | RestElement;
208
+
177
209
  interface BaseFunction extends BaseNode {
178
- +params: $ReadOnlyArray<Pattern>;
210
+ +params: $ReadOnlyArray<FunctionParameter>;
179
211
  +async: boolean;
180
212
 
181
213
  +predicate: null | InferredPredicate;
@@ -210,7 +242,9 @@ export type Statement =
210
242
  | TypeAlias
211
243
  | OpaqueType
212
244
  | InterfaceDeclaration
213
- | Declaration
245
+ | FunctionDeclaration
246
+ | VariableDeclaration
247
+ | ClassDeclaration
214
248
  | DeclareTypeAlias
215
249
  | DeclareOpaqueType
216
250
  | DeclareInterface
@@ -318,7 +352,7 @@ export interface ForStatement extends BaseNode {
318
352
  }
319
353
 
320
354
  interface BaseForXStatement extends BaseNode {
321
- +left: VariableDeclaration | Pattern;
355
+ +left: VariableDeclaration | BindingName | MemberExpression;
322
356
  +right: Expression;
323
357
  +body: Statement;
324
358
  }
@@ -336,11 +370,6 @@ export interface DebuggerStatement extends BaseNode {
336
370
  +type: 'DebuggerStatement';
337
371
  }
338
372
 
339
- export type Declaration =
340
- | FunctionDeclaration
341
- | VariableDeclaration
342
- | ClassDeclaration;
343
-
344
373
  export interface FunctionDeclaration extends BaseFunction {
345
374
  +type: 'FunctionDeclaration';
346
375
  /** It is null when a function declaration is a part of the `export default function` statement */
@@ -357,7 +386,7 @@ export interface VariableDeclaration extends BaseNode {
357
386
 
358
387
  export interface VariableDeclarator extends BaseNode {
359
388
  +type: 'VariableDeclarator';
360
- +id: Pattern;
389
+ +id: BindingName;
361
390
  +init?: Expression | null;
362
391
  }
363
392
 
@@ -375,10 +404,8 @@ export type Expression =
375
404
  | AssignmentExpression
376
405
  | LogicalExpression
377
406
  | MemberExpression
378
- | OptionalMemberExpression
379
407
  | ConditionalExpression
380
408
  | CallExpression
381
- | OptionalCallExpression
382
409
  | NewExpression
383
410
  | SequenceExpression
384
411
  | TemplateLiteral
@@ -390,7 +417,8 @@ export type Expression =
390
417
  | ImportExpression
391
418
  | ChainExpression
392
419
  | TypeCastExpression
393
- | PrivateName;
420
+ | JSXFragment
421
+ | JSXElement;
394
422
 
395
423
  export interface ThisExpression extends BaseNode {
396
424
  +type: 'ThisExpression';
@@ -405,30 +433,91 @@ export interface ArrayExpression extends BaseNode {
405
433
 
406
434
  export interface ObjectExpression extends BaseNode {
407
435
  +type: 'ObjectExpression';
408
- +properties: $ReadOnlyArray<Property | SpreadElement>;
436
+ +properties: $ReadOnlyArray<ObjectProperty | SpreadElement>;
409
437
  }
410
438
 
411
- interface PropertyBase extends BaseNode {
412
- +key: Expression;
413
- +shorthand: boolean;
414
- +computed: boolean;
415
- }
439
+ // This is the complete type of a "Property"
440
+ // This same node (unfortunately) covers both object literal properties
441
+ // and object desturcturing properties.
442
+ export type Property = ObjectProperty | DestructuringObjectProperty;
416
443
 
417
- export interface Property extends PropertyBase {
444
+ export type ObjectProperty =
445
+ | ObjectPropertyWithNonShorthandStaticName
446
+ | ObjectPropertyWithShorthandStaticName
447
+ | ObjectPropertyWithComputedName;
448
+ export interface ObjectPropertyWithNonShorthandStaticName extends BaseNode {
418
449
  +type: 'Property';
419
- +value: Expression | Pattern; // Could be an AssignmentProperty
450
+ +computed: false;
451
+ // non-computed, non-shorthand names are constrained significantly
452
+ +key: Identifier | StringLiteral | NumericLiteral;
453
+ +value: Expression;
420
454
  +kind: 'init' | 'get' | 'set';
421
455
  +method: boolean;
456
+ +shorthand: false;
422
457
  }
423
-
424
- // this is a special type of property
425
- // we can't use `interface ... extends` here because it's a sub-type
426
- export interface AssignmentProperty extends PropertyBase {
458
+ export interface ObjectPropertyWithShorthandStaticName extends BaseNode {
427
459
  +type: 'Property';
428
- +value: Pattern;
460
+ +computed: false;
461
+ // shorthand keys *must* be identifiers
462
+ +key: Identifier;
463
+ // shorthand values *must* be identifiers (that look the same as the key)
464
+ +value: Identifier;
465
+ +kind: 'init';
466
+ +method: boolean;
467
+ +shorthand: true;
468
+ }
469
+ export interface ObjectPropertyWithComputedName extends BaseNode {
470
+ +type: 'Property';
471
+ +computed: true;
472
+ // computed names can be any expression
473
+ +key: Expression;
474
+ +value: Expression;
475
+ +kind: 'init' | 'get' | 'set';
476
+ +method: boolean;
477
+ // cannot have a shorthand computed name
478
+ +shorthand: false;
479
+ }
480
+
481
+ export type DestructuringObjectProperty =
482
+ | DestructuringObjectPropertyWithNonShorthandStaticName
483
+ | DestructuringObjectPropertyWithShorthandStaticName
484
+ | DestructuringObjectPropertyWithComputedName;
485
+ interface DestructuringObjectPropertyBase extends BaseNode {
486
+ // destructuring properties cannot be methods
429
487
  +kind: 'init';
430
488
  +method: false;
431
489
  }
490
+ export interface DestructuringObjectPropertyWithNonShorthandStaticName
491
+ extends DestructuringObjectPropertyBase {
492
+ +type: 'Property';
493
+ +computed: false;
494
+ // non-computed, non-shorthand names are constrained significantly
495
+ +key: Identifier | StringLiteral | NumericLiteral;
496
+ // destructuring properties cannot have any value
497
+ +value: DestructuringPattern;
498
+ +shorthand: false;
499
+ }
500
+ export interface DestructuringObjectPropertyWithShorthandStaticName
501
+ extends DestructuringObjectPropertyBase {
502
+ +type: 'Property';
503
+ +computed: false;
504
+ // shorthand keys *must* be identifiers
505
+ +key: Identifier;
506
+ // shorthand values *must* be identifiers (that look the same as the key)
507
+ +value: Identifier;
508
+ +shorthand: true;
509
+ }
510
+ export interface DestructuringObjectPropertyWithComputedName
511
+ extends DestructuringObjectPropertyBase {
512
+ +type: 'Property';
513
+ +computed: true;
514
+ // computed names can be any expression
515
+ +key: Expression;
516
+ // destructuring properties cannot have any value
517
+ +value: DestructuringPattern;
518
+ // cannot have a shorthand computed name
519
+ +shorthand: false;
520
+ }
432
521
 
433
522
  export interface FunctionExpression extends BaseFunction {
434
523
  +id?: Identifier | null;
@@ -449,17 +538,28 @@ export interface UnaryExpression extends BaseNode {
449
538
  +argument: Expression;
450
539
  }
451
540
 
452
- export interface BinaryExpression extends BaseNode {
541
+ export interface BinaryExpressionWithoutIn extends BaseNode {
453
542
  +type: 'BinaryExpression';
454
- +operator: BinaryOperator;
543
+ +operator: BinaryOperatorWithoutIn;
455
544
  +left: Expression;
456
545
  +right: Expression;
457
546
  }
458
547
 
548
+ // Private brand checks (#foo in bar) are a special case
549
+ // other binary expressions do not allow PrivateIdentifier in the left
550
+ export interface BinaryExpressionIn extends BaseNode {
551
+ +type: 'BinaryExpression';
552
+ +operator: 'in';
553
+ +left: Expression | PrivateIdentifier;
554
+ +right: Expression;
555
+ }
556
+
557
+ export type BinaryExpression = BinaryExpressionWithoutIn | BinaryExpressionIn;
558
+
459
559
  export interface AssignmentExpression extends BaseNode {
460
560
  +type: 'AssignmentExpression';
461
561
  +operator: AssignmentOperator;
462
- +left: Pattern | MemberExpression;
562
+ +left: BindingName | MemberExpression;
463
563
  +right: Expression;
464
564
  }
465
565
 
@@ -491,19 +591,31 @@ interface BaseCallExpression extends BaseNode {
491
591
  }
492
592
  export interface CallExpression extends BaseCallExpression {
493
593
  +type: 'CallExpression';
594
+ +optional: boolean;
494
595
  }
495
596
 
496
597
  export interface NewExpression extends BaseCallExpression {
497
598
  +type: 'NewExpression';
498
599
  }
499
600
 
500
- interface BaseMemberExpression extends BaseNode {
601
+ export type MemberExpression =
602
+ | MemberExpressionWithComputedName
603
+ | MemberExpressionWithNonComputedName;
604
+ export interface MemberExpressionWithComputedName extends BaseNode {
605
+ +type: 'MemberExpression';
606
+ +computed: true;
501
607
  +object: Expression | Super;
502
608
  +property: Expression;
503
- +computed: boolean;
609
+ +computed: true;
610
+ +optional: boolean;
504
611
  }
505
- export interface MemberExpression extends BaseMemberExpression {
612
+ export interface MemberExpressionWithNonComputedName extends BaseNode {
506
613
  +type: 'MemberExpression';
614
+ +computed: false;
615
+ +object: Expression | Super;
616
+ +property: Identifier | PrivateIdentifier;
617
+ +computed: false;
618
+ +optional: boolean;
507
619
  }
508
620
 
509
621
  export type ChainElement = CallExpression | MemberExpression;
@@ -513,14 +625,6 @@ export interface ChainExpression extends BaseNode {
513
625
  +expression: ChainElement;
514
626
  }
515
627
 
516
- export type Pattern =
517
- | Identifier
518
- | ObjectPattern
519
- | ArrayPattern
520
- | RestElement
521
- | AssignmentPattern
522
- | MemberExpression;
523
-
524
628
  export interface SwitchCase extends BaseNode {
525
629
  +type: 'SwitchCase';
526
630
  +test?: Expression | null;
@@ -529,7 +633,7 @@ export interface SwitchCase extends BaseNode {
529
633
 
530
634
  export interface CatchClause extends BaseNode {
531
635
  +type: 'CatchClause';
532
- +param: Pattern | null;
636
+ +param: BindingName | null;
533
637
  +body: BlockStatement;
534
638
  }
535
639
 
@@ -542,9 +646,13 @@ export interface Identifier extends BaseNode {
542
646
  +optional: boolean;
543
647
  }
544
648
 
649
+ export interface PrivateIdentifier extends BaseNode {
650
+ +type: 'PrivateIdentifier';
651
+ +name: string;
652
+ }
653
+
545
654
  export type Literal =
546
655
  | BigIntLiteral
547
- | BigIntLiteralLegacy
548
656
  | BooleanLiteral
549
657
  | NullLiteral
550
658
  | NumericLiteral
@@ -556,24 +664,28 @@ export interface BigIntLiteral extends BaseNode {
556
664
  +value: null /* | bigint */;
557
665
  +bigint: string;
558
666
  +raw: string;
667
+ +literalType: 'bigint';
559
668
  }
560
669
 
561
670
  export interface BooleanLiteral extends BaseNode {
562
671
  +type: 'Literal';
563
672
  +value: boolean;
564
673
  +raw: 'true' | 'false';
674
+ +literalType: 'boolean';
565
675
  }
566
676
 
567
677
  export interface NullLiteral extends BaseNode {
568
678
  +type: 'Literal';
569
679
  +value: null;
570
680
  +raw: 'null';
681
+ +literalType: 'null';
571
682
  }
572
683
 
573
684
  export interface NumericLiteral extends BaseNode {
574
685
  +type: 'Literal';
575
686
  +value: number;
576
687
  +raw: string;
688
+ +literalType: 'numeric';
577
689
  }
578
690
 
579
691
  export interface RegExpLiteral extends BaseNode {
@@ -584,12 +696,14 @@ export interface RegExpLiteral extends BaseNode {
584
696
  +flags: string,
585
697
  };
586
698
  +raw: string;
699
+ +literalType: 'regexp';
587
700
  }
588
701
 
589
702
  export interface StringLiteral extends BaseNode {
590
703
  +type: 'Literal';
591
704
  +value: string;
592
705
  +raw: string;
706
+ +literalType: 'string';
593
707
  }
594
708
 
595
709
  export type UnaryOperator =
@@ -601,7 +715,7 @@ export type UnaryOperator =
601
715
  | 'void'
602
716
  | 'delete';
603
717
 
604
- export type BinaryOperator =
718
+ export type BinaryOperatorWithoutIn =
605
719
  | '=='
606
720
  | '!='
607
721
  | '==='
@@ -622,10 +736,11 @@ export type BinaryOperator =
622
736
  | '|'
623
737
  | '^'
624
738
  | '&'
625
- | 'in'
626
739
  | 'instanceof';
627
740
 
628
- export type LogicalOperator = '||' | '&&';
741
+ export type BinaryOperator = BinaryOperatorWithoutIn | 'in';
742
+
743
+ export type LogicalOperator = '||' | '&&' | '??';
629
744
 
630
745
  export type AssignmentOperator =
631
746
  | '='
@@ -640,7 +755,11 @@ export type AssignmentOperator =
640
755
  | '>>>='
641
756
  | '|='
642
757
  | '^='
643
- | '&=';
758
+ | '&='
759
+ // not yet supported, but future proofing
760
+ | '||='
761
+ | '&&='
762
+ | '??=';
644
763
 
645
764
  export type UpdateOperator = '++' | '--';
646
765
 
@@ -691,27 +810,27 @@ export interface TemplateElement extends BaseNode {
691
810
 
692
811
  export interface ObjectPattern extends BaseNode {
693
812
  +type: 'ObjectPattern';
694
- +properties: $ReadOnlyArray<AssignmentProperty | RestElement>;
813
+ +properties: $ReadOnlyArray<DestructuringObjectProperty | RestElement>;
695
814
  // if used as a VariableDeclarator.id
696
815
  +typeAnnotation: TypeAnnotation | null;
697
816
  }
698
817
 
699
818
  export interface ArrayPattern extends BaseNode {
700
819
  +type: 'ArrayPattern';
701
- +elements: $ReadOnlyArray<Pattern>;
702
-
820
+ // an element will be null if the pattern contains a hole: `[a,,b]`
821
+ +elements: $ReadOnlyArray<?DestructuringPattern>;
703
822
  +typeAnnotation: TypeAnnotation | null;
704
823
  }
705
824
 
706
825
  export interface RestElement extends BaseNode {
707
826
  +type: 'RestElement';
708
- +argument: Pattern;
827
+ +argument: RestElementPattern;
709
828
  // the Pattern owns the typeAnnotation
710
829
  }
711
830
 
712
831
  export interface AssignmentPattern extends BaseNode {
713
832
  +type: 'AssignmentPattern';
714
- +left: Pattern;
833
+ +left: BindingName;
715
834
  +right: Expression;
716
835
  }
717
836
 
@@ -726,21 +845,80 @@ interface BaseClass extends BaseNode {
726
845
  +decorators: $ReadOnlyArray<Decorator>;
727
846
  }
728
847
 
848
+ export type PropertyName =
849
+ | ClassPropertyNameComputed
850
+ | ClassPropertyNameNonComputed;
851
+ export type ClassPropertyNameComputed = Expression;
852
+ export type ClassPropertyNameNonComputed =
853
+ | PrivateIdentifier
854
+ | Identifier
855
+ | StringLiteral;
856
+
857
+ export type ClassMember = PropertyDefinition | MethodDefinition;
858
+ export type ClassMemberWithNonComputedName =
859
+ | PropertyDefinitionWithNonComputedName
860
+ | MethodDefinitionConstructor
861
+ | MethodDefinitionWithNonComputedName;
729
862
  export interface ClassBody extends BaseNode {
730
863
  +type: 'ClassBody';
731
- +body: $ReadOnlyArray<
732
- ClassProperty | ClassPrivateProperty | MethodDefinition,
733
- >;
864
+ +body: $ReadOnlyArray<ClassMember>;
734
865
  }
735
866
 
736
- export interface MethodDefinition extends BaseNode {
737
- +type: 'MethodDefinition';
738
- +key: Expression;
867
+ export type MethodDefinition =
868
+ | MethodDefinitionConstructor
869
+ | MethodDefinitionWithComputedName
870
+ | MethodDefinitionWithNonComputedName;
871
+ interface MethodDefinitionBase extends BaseNode {
739
872
  +value: FunctionExpression;
740
- +kind: 'constructor' | 'method' | 'get' | 'set';
741
- +computed: boolean;
873
+ }
874
+ export interface MethodDefinitionConstructor extends MethodDefinitionBase {
875
+ +type: 'MethodDefinition';
876
+ +key: Identifier | StringLiteral;
877
+ +kind: 'constructor';
878
+ +computed: false;
879
+ +static: false;
880
+ }
881
+ export interface MethodDefinitionWithComputedName extends MethodDefinitionBase {
882
+ +type: 'MethodDefinition';
883
+ +key: ClassPropertyNameComputed;
884
+ +kind: 'method' | 'get' | 'set';
885
+ +computed: true;
742
886
  +static: boolean;
743
887
  }
888
+ export interface MethodDefinitionWithNonComputedName
889
+ extends MethodDefinitionBase {
890
+ +type: 'MethodDefinition';
891
+ +key: ClassPropertyNameNonComputed;
892
+ +kind: 'method' | 'get' | 'set';
893
+ +computed: false;
894
+ +static: boolean;
895
+ }
896
+
897
+ // `PropertyDefinition` is the new standard for all class properties
898
+ export type PropertyDefinition =
899
+ | PropertyDefinitionWithComputedName
900
+ | PropertyDefinitionWithNonComputedName;
901
+ interface PropertyDefinitionBase extends BaseNode {
902
+ +value: null | Expression;
903
+ +typeAnnotation: null | TypeAnnotation;
904
+ +static: boolean;
905
+ +variance: null | Variance;
906
+ +declare: boolean;
907
+ // hermes always emit this as false
908
+ +optional: false;
909
+ }
910
+ export interface PropertyDefinitionWithComputedName
911
+ extends PropertyDefinitionBase {
912
+ +type: 'PropertyDefinition';
913
+ +key: ClassPropertyNameComputed;
914
+ +computed: true;
915
+ }
916
+ export interface PropertyDefinitionWithNonComputedName
917
+ extends PropertyDefinitionBase {
918
+ +type: 'PropertyDefinition';
919
+ +key: ClassPropertyNameNonComputed;
920
+ +computed: false;
921
+ }
744
922
 
745
923
  export interface ClassDeclaration extends BaseClass {
746
924
  +type: 'ClassDeclaration';
@@ -772,8 +950,7 @@ export type ModuleSpecifier =
772
950
  | ImportSpecifier
773
951
  | ImportDefaultSpecifier
774
952
  | ImportNamespaceSpecifier
775
- | ExportSpecifier
776
- | ExportNamespaceSpecifier;
953
+ | ExportSpecifier;
777
954
 
778
955
  export interface ImportDeclaration extends BaseNode {
779
956
  +type: 'ImportDeclaration';
@@ -814,10 +991,19 @@ export interface ImportNamespaceSpecifier extends BaseNode {
814
991
  +local: Identifier;
815
992
  }
816
993
 
994
+ export type DefaultDeclaration = FunctionDeclaration | ClassDeclaration;
995
+ export type NamedDeclaration =
996
+ | DefaultDeclaration
997
+ | VariableDeclaration
998
+ | TypeAlias
999
+ | OpaqueType
1000
+ | InterfaceDeclaration
1001
+ | EnumDeclaration;
1002
+
817
1003
  export interface ExportNamedDeclaration extends BaseNode {
818
1004
  +type: 'ExportNamedDeclaration';
819
- +declaration?: Declaration | null;
820
- +specifiers: $ReadOnlyArray<ExportSpecifier | ExportNamespaceSpecifier>;
1005
+ +declaration?: NamedDeclaration | null;
1006
+ +specifiers: $ReadOnlyArray<ExportSpecifier>;
821
1007
  +source?: Literal | null;
822
1008
  +exportKind: 'value' | 'type';
823
1009
  }
@@ -830,15 +1016,14 @@ export interface ExportSpecifier extends BaseNode {
830
1016
 
831
1017
  export interface ExportDefaultDeclaration extends BaseNode {
832
1018
  +type: 'ExportDefaultDeclaration';
833
- +declaration: Declaration | Expression;
1019
+ +declaration: DefaultDeclaration | Expression;
834
1020
  }
835
1021
 
836
1022
  export interface ExportAllDeclaration extends BaseNode {
837
1023
  +type: 'ExportAllDeclaration';
838
1024
  +source: Literal;
839
1025
  +exportKind: 'value' | 'type';
840
- // uncomment this when hermes stops using ExportNamespaceSpecifier
841
- // +exported: Identifier;
1026
+ +exported?: Identifier | null;
842
1027
  }
843
1028
 
844
1029
  export interface AwaitExpression extends BaseNode {
@@ -863,6 +1048,7 @@ export type TypeAnnotationType =
863
1048
  | VoidTypeAnnotation
864
1049
  | StringLiteralTypeAnnotation
865
1050
  | NumberLiteralTypeAnnotation
1051
+ | BigIntLiteralTypeAnnotation
866
1052
  | BooleanLiteralTypeAnnotation
867
1053
  | ArrayTypeAnnotation
868
1054
  | NullableTypeAnnotation
@@ -942,12 +1128,18 @@ export interface VoidTypeAnnotation extends BaseNode {
942
1128
  export interface StringLiteralTypeAnnotation extends BaseNode {
943
1129
  +type: 'StringLiteralTypeAnnotation';
944
1130
  +value: string;
1131
+ +raw: string;
945
1132
  }
946
1133
  export interface NumberLiteralTypeAnnotation extends BaseNode {
947
1134
  +type: 'NumberLiteralTypeAnnotation';
948
1135
  +value: number;
949
1136
  +raw: string;
950
1137
  }
1138
+ export interface BigIntLiteralTypeAnnotation extends BaseNode {
1139
+ +type: 'BigIntLiteralTypeAnnotation';
1140
+ +value: null;
1141
+ +raw: string;
1142
+ }
951
1143
  export interface BooleanLiteralTypeAnnotation extends BaseNode {
952
1144
  +type: 'BooleanLiteralTypeAnnotation';
953
1145
  +value: boolean;
@@ -966,7 +1158,7 @@ export interface ExistsTypeAnnotation extends BaseNode {
966
1158
  }
967
1159
  export interface GenericTypeAnnotation extends BaseNode {
968
1160
  +type: 'GenericTypeAnnotation';
969
- +id: Identifier;
1161
+ +id: Identifier | QualifiedTypeIdentifier;
970
1162
  +typeParameters: null | TypeParameterInstantiation;
971
1163
  }
972
1164
  export interface QualifiedTypeIdentifier extends BaseNode {
@@ -976,7 +1168,7 @@ export interface QualifiedTypeIdentifier extends BaseNode {
976
1168
  }
977
1169
  export interface TypeofTypeAnnotation extends BaseNode {
978
1170
  +type: 'TypeofTypeAnnotation';
979
- +argument: GenericTypeAnnotation | QualifiedTypeIdentifier;
1171
+ +argument: TypeAnnotationType;
980
1172
  }
981
1173
  export interface TupleTypeAnnotation extends BaseNode {
982
1174
  +type: 'TupleTypeAnnotation';
@@ -1099,17 +1291,6 @@ export interface InterfaceExtends extends BaseNode {
1099
1291
  +typeParameters: null | TypeParameterDeclaration;
1100
1292
  }
1101
1293
 
1102
- interface ClassPropertyBase extends BaseNode {
1103
- +key: Identifier;
1104
- +value: null | Literal;
1105
- +typeAnnotation: null | TypeAnnotationType;
1106
- +static: boolean;
1107
- +variance: null | Variance;
1108
- +declare: boolean;
1109
- // hermes always emit this as false
1110
- +optional: false;
1111
- }
1112
-
1113
1294
  export interface ClassImplements extends BaseNode {
1114
1295
  +type: 'ClassImplements';
1115
1296
  +id: Identifier;
@@ -1201,6 +1382,19 @@ export interface EnumDefaultedMember extends BaseNode {
1201
1382
  * Declare nodes *
1202
1383
  *****************/
1203
1384
 
1385
+ export type DeclaredNode =
1386
+ | DeclareClass
1387
+ | DeclareVariable
1388
+ | DeclareFunction
1389
+ | DeclareModule
1390
+ | DeclareInterface
1391
+ | DeclareTypeAlias
1392
+ | DeclareOpaqueType
1393
+ | DeclareExportAllDeclaration
1394
+ | DeclareExportDeclaration
1395
+ | DeclareModuleExports
1396
+ | DeclaredPredicate;
1397
+
1204
1398
  export interface DeclareClass extends BaseNode {
1205
1399
  +type: 'DeclareClass';
1206
1400
  +id: Identifier;
@@ -1219,7 +1413,7 @@ export interface DeclareVariable extends BaseNode {
1219
1413
  export interface DeclareFunction extends BaseNode {
1220
1414
  +type: 'DeclareFunction';
1221
1415
  +id: Identifier;
1222
- +predicate: InferredPredicate | null;
1416
+ +predicate: InferredPredicate | DeclaredPredicate | null;
1223
1417
  }
1224
1418
 
1225
1419
  export interface DeclareModule extends BaseNode {
@@ -1251,7 +1445,7 @@ export interface DeclareExportDeclaration extends BaseNode {
1251
1445
  +type: 'DeclareExportDeclaration';
1252
1446
  +specifiers: $ReadOnlyArray<ExportSpecifier>;
1253
1447
  +declaration:
1254
- | TypeAnnotationType
1448
+ | TypeAlias
1255
1449
  | DeclareClass
1256
1450
  | DeclareFunction
1257
1451
  | DeclareOpaqueType
@@ -1390,42 +1584,4 @@ export interface JSXSpreadChild extends BaseNode {
1390
1584
  * Deprecated spec nodes awaiting migration by Hermes *
1391
1585
  ******************************************************/
1392
1586
 
1393
- // `ChainExpression` is the new standard for optional chaining
1394
- export interface OptionalCallExpression extends BaseCallExpression {
1395
- +type: 'OptionalCallExpression';
1396
- +optional: boolean;
1397
- }
1398
- export interface OptionalMemberExpression extends BaseMemberExpression {
1399
- +type: 'OptionalMemberExpression';
1400
- +optional: boolean;
1401
- }
1402
-
1403
- // `ExportAllDeclaration` is the new standard for `export * as y from 'z'`
1404
- export interface ExportNamespaceSpecifier extends BaseNode {
1405
- +type: 'ExportNamespaceSpecifier';
1406
- +exported: Identifier;
1407
- }
1408
-
1409
- // `Literal` is the new standard for bigints (see the BigIntLiteral interface)
1410
- export interface BigIntLiteralLegacy extends BaseNode {
1411
- +type: 'BigIntLiteral';
1412
- +value: null /* | bigint */;
1413
- +bigint: string;
1414
- }
1415
-
1416
- // `PropertyDefinition` is the new standard for all class properties
1417
- export interface ClassProperty extends ClassPropertyBase {
1418
- +type: 'ClassProperty';
1419
- +computed: false; // flow itself doesn't support computed ClassProperties, even though they might parse fine.
1420
- }
1421
- export interface ClassPrivateProperty extends ClassPropertyBase {
1422
- +type: 'ClassPrivateProperty';
1423
- }
1424
-
1425
- // `PrivateIdentifier` is the new standard for #private identifiers
1426
- export interface PrivateName extends BaseNode {
1427
- +type: 'PrivateName';
1428
- +id: Identifier;
1429
- }
1430
-
1431
1587
  export {};