@@ -10,6 +10,7 @@ module.exports = function defineGrammar(dialect) {
10
10
] ) ,
11
11
12
12
supertypes : ( $ , previous ) => previous . concat ( [
13
+ $ . type ,
13
14
$ . primary_type ,
14
15
] ) ,
15
16
@@ -42,13 +43,13 @@ module.exports = function defineGrammar(dialect) {
42
43
[ 'unary' , 'assign' ] ,
43
44
[ 'declaration' , $ . expression ] ,
44
45
[ $ . predefined_type , $ . unary_expression ] ,
45
- [ $ . _type , $ . flow_maybe_type ] ,
46
- [ $ . tuple_type , $ . array_type , $ . pattern , $ . _type ] ,
46
+ [ $ . type , $ . flow_maybe_type ] ,
47
+ [ $ . tuple_type , $ . array_type , $ . pattern , $ . type ] ,
47
48
[ $ . readonly_type , $ . pattern ] ,
48
49
[ $ . readonly_type , $ . primary_expression ] ,
49
50
[ $ . type_query , $ . subscript_expression , $ . expression ] ,
50
51
[ $ . type_query , $ . _type_query_subscript_expression ] ,
51
- [ $ . nested_type_identifier , $ . generic_type , $ . primary_type , $ . lookup_type , $ . index_type_query , $ . _type ] ,
52
+ [ $ . nested_type_identifier , $ . generic_type , $ . primary_type , $ . lookup_type , $ . index_type_query , $ . type ] ,
52
53
[ $ . as_expression , $ . satisfies_expression , $ . primary_type ] ,
53
54
[ $ . _type_query_member_expression , $ . member_expression ] ,
54
55
[ $ . member_expression , $ . _type_query_member_expression_in_type_annotation ] ,
@@ -457,13 +458,13 @@ module.exports = function defineGrammar(dialect) {
457
458
as_expression : $ => prec . left ( 'binary' , seq (
458
459
$ . expression ,
459
460
'as' ,
460
- choice ( 'const' , $ . _type ) ,
461
+ choice ( 'const' , $ . type ) ,
461
462
) ) ,
462
463
463
464
satisfies_expression : $ => prec . left ( 'binary' , seq (
464
465
$ . expression ,
465
466
'satisfies' ,
466
- $ . _type ,
467
+ $ . type ,
467
468
) ) ,
468
469
469
470
instantiation_expression : $ => prec ( 'instantiation' , seq (
@@ -497,15 +498,15 @@ module.exports = function defineGrammar(dialect) {
497
498
498
499
implements_clause : $ => seq (
499
500
'implements' ,
500
- commaSep1 ( $ . _type ) ,
501
+ commaSep1 ( $ . type ) ,
501
502
) ,
502
503
503
504
ambient_declaration : $ => seq (
504
505
'declare' ,
505
506
choice (
506
507
$ . declaration ,
507
508
seq ( 'global' , $ . statement_block ) ,
508
- seq ( 'module' , '.' , alias ( $ . identifier , $ . property_identifier ) , ':' , $ . _type , $ . _semicolon ) ,
509
+ seq ( 'module' , '.' , alias ( $ . identifier , $ . property_identifier ) , ':' , $ . type , $ . _semicolon ) ,
509
510
) ,
510
511
) ,
511
512
@@ -615,7 +616,7 @@ module.exports = function defineGrammar(dialect) {
615
616
field ( 'name' , $ . _type_identifier ) ,
616
617
field ( 'type_parameters' , optional ( $ . type_parameters ) ) ,
617
618
'=' ,
618
- field ( 'value' , $ . _type ) ,
619
+ field ( 'value' , $ . type ) ,
619
620
$ . _semicolon ,
620
621
) ,
621
622
@@ -648,13 +649,13 @@ module.exports = function defineGrammar(dialect) {
648
649
field ( 'pattern' , choice ( $ . pattern , $ . this ) ) ,
649
650
) ,
650
651
651
- omitting_type_annotation : $ => seq ( '-?:' , $ . _type ) ,
652
- adding_type_annotation : $ => seq ( '+?:' , $ . _type ) ,
653
- opting_type_annotation : $ => seq ( '?:' , $ . _type ) ,
652
+ omitting_type_annotation : $ => seq ( '-?:' , $ . type ) ,
653
+ adding_type_annotation : $ => seq ( '+?:' , $ . type ) ,
654
+ opting_type_annotation : $ => seq ( '?:' , $ . type ) ,
654
655
type_annotation : $ => seq (
655
656
':' ,
656
657
choice (
657
- $ . _type ,
658
+ $ . type ,
658
659
alias ( $ . _type_query_member_expression_in_type_annotation , $ . member_expression ) ,
659
660
alias ( $ . _type_query_call_expression_in_type_annotation , $ . call_expression ) ,
660
661
) ,
@@ -695,7 +696,7 @@ module.exports = function defineGrammar(dialect) {
695
696
seq ( ':' , $ . asserts ) ,
696
697
) ,
697
698
698
- _type : $ => choice (
699
+ type : $ => choice (
699
700
$ . primary_type ,
700
701
$ . function_type ,
701
702
$ . readonly_type ,
@@ -714,15 +715,15 @@ module.exports = function defineGrammar(dialect) {
714
715
field ( 'type' , $ . type_annotation ) ,
715
716
) ,
716
717
717
- optional_type : $ => seq ( $ . _type , '?' ) ,
718
- rest_type : $ => seq ( '...' , $ . _type ) ,
718
+ optional_type : $ => seq ( $ . type , '?' ) ,
719
+ rest_type : $ => seq ( '...' , $ . type ) ,
719
720
720
721
_tuple_type_member : $ => choice (
721
722
alias ( $ . tuple_parameter , $ . required_parameter ) ,
722
723
alias ( $ . optional_tuple_parameter , $ . optional_parameter ) ,
723
724
$ . optional_type ,
724
725
$ . rest_type ,
725
- $ . _type ,
726
+ $ . type ,
726
727
) ,
727
728
728
729
constructor_type : $ => prec . left ( seq (
@@ -731,7 +732,7 @@ module.exports = function defineGrammar(dialect) {
731
732
field ( 'type_parameters' , optional ( $ . type_parameters ) ) ,
732
733
field ( 'parameters' , $ . formal_parameters ) ,
733
734
'=>' ,
734
- field ( 'type' , $ . _type ) ,
735
+ field ( 'type' , $ . type ) ,
735
736
) ) ,
736
737
737
738
primary_type : $ => choice (
@@ -773,18 +774,18 @@ module.exports = function defineGrammar(dialect) {
773
774
$ . _type_identifier ,
774
775
optional ( seq (
775
776
'extends' ,
776
- $ . _type ,
777
+ $ . type ,
777
778
) ) ,
778
779
) ) ,
779
780
780
781
conditional_type : $ => prec . right ( seq (
781
- field ( 'left' , $ . _type ) ,
782
+ field ( 'left' , $ . type ) ,
782
783
'extends' ,
783
- field ( 'right' , $ . _type ) ,
784
+ field ( 'right' , $ . type ) ,
784
785
'?' ,
785
- field ( 'consequence' , $ . _type ) ,
786
+ field ( 'consequence' , $ . type ) ,
786
787
':' ,
787
- field ( 'alternative' , $ . _type ) ,
788
+ field ( 'alternative' , $ . type ) ,
788
789
) ) ,
789
790
790
791
generic_type : $ => prec ( 'call' , seq (
@@ -807,7 +808,7 @@ module.exports = function defineGrammar(dialect) {
807
808
alias ( $ . predefined_type , $ . identifier ) ,
808
809
) ) ,
809
810
'is' ,
810
- field ( 'type' , $ . _type ) ,
811
+ field ( 'type' , $ . type ) ,
811
812
) ,
812
813
813
814
type_predicate_annotation : $ => seq (
@@ -875,15 +876,15 @@ module.exports = function defineGrammar(dialect) {
875
876
lookup_type : $ => seq (
876
877
$ . primary_type ,
877
878
'[' ,
878
- $ . _type ,
879
+ $ . type ,
879
880
']' ,
880
881
) ,
881
882
882
883
mapped_type_clause : $ => seq (
883
884
field ( 'name' , $ . _type_identifier ) ,
884
885
'in' ,
885
- field ( 'type' , $ . _type ) ,
886
- optional ( seq ( 'as' , field ( 'alias' , $ . _type ) ) ) ,
886
+ field ( 'type' , $ . type ) ,
887
+ optional ( seq ( 'as' , field ( 'alias' , $ . type ) ) ) ,
887
888
) ,
888
889
889
890
literal_type : $ => choice (
@@ -905,7 +906,7 @@ module.exports = function defineGrammar(dialect) {
905
906
906
907
flow_maybe_type : $ => prec . right ( seq ( '?' , $ . primary_type ) ) ,
907
908
908
- parenthesized_type : $ => seq ( '(' , $ . _type , ')' ) ,
909
+ parenthesized_type : $ => seq ( '(' , $ . type , ')' ) ,
909
910
910
911
predefined_type : _ => choice (
911
912
'any' ,
@@ -924,7 +925,7 @@ module.exports = function defineGrammar(dialect) {
924
925
type_arguments : $ => seq (
925
926
'<' ,
926
927
commaSep1 ( choice (
927
- $ . _type ,
928
+ $ . type ,
928
929
alias ( $ . _type_query_member_expression_in_type_annotation , $ . member_expression ) ,
929
930
alias ( $ . _type_query_call_expression_in_type_annotation , $ . call_expression ) ,
930
931
) ) ,
@@ -985,12 +986,12 @@ module.exports = function defineGrammar(dialect) {
985
986
986
987
default_type : $ => seq (
987
988
'=' ,
988
- $ . _type ,
989
+ $ . type ,
989
990
) ,
990
991
991
992
constraint : $ => seq (
992
993
choice ( 'extends' , ':' ) ,
993
- $ . _type ,
994
+ $ . type ,
994
995
) ,
995
996
996
997
construct_signature : $ => seq (
@@ -1016,7 +1017,7 @@ module.exports = function defineGrammar(dialect) {
1016
1017
alias ( $ . _reserved_identifier , $ . identifier ) ,
1017
1018
) ) ,
1018
1019
':' ,
1019
- field ( 'index_type' , $ . _type ) ,
1020
+ field ( 'index_type' , $ . type ) ,
1020
1021
) ,
1021
1022
$ . mapped_type_clause ,
1022
1023
) ,
@@ -1033,16 +1034,16 @@ module.exports = function defineGrammar(dialect) {
1033
1034
tuple_type : $ => seq (
1034
1035
'[' , commaSep ( $ . _tuple_type_member ) , optional ( ',' ) , ']' ,
1035
1036
) ,
1036
- readonly_type : $ => seq ( 'readonly' , $ . _type ) ,
1037
+ readonly_type : $ => seq ( 'readonly' , $ . type ) ,
1037
1038
1038
- union_type : $ => prec . left ( seq ( optional ( $ . _type ) , '|' , $ . _type ) ) ,
1039
- intersection_type : $ => prec . left ( seq ( optional ( $ . _type ) , '&' , $ . _type ) ) ,
1039
+ union_type : $ => prec . left ( seq ( optional ( $ . type ) , '|' , $ . type ) ) ,
1040
+ intersection_type : $ => prec . left ( seq ( optional ( $ . type ) , '&' , $ . type ) ) ,
1040
1041
1041
1042
function_type : $ => prec . left ( seq (
1042
1043
field ( 'type_parameters' , optional ( $ . type_parameters ) ) ,
1043
1044
field ( 'parameters' , $ . formal_parameters ) ,
1044
1045
'=>' ,
1045
- field ( 'return_type' , choice ( $ . _type , $ . asserts , $ . type_predicate ) ) ,
1046
+ field ( 'return_type' , choice ( $ . type , $ . asserts , $ . type_predicate ) ) ,
1046
1047
) ) ,
1047
1048
1048
1049
_type_identifier : $ => alias ( $ . identifier , $ . type_identifier ) ,
0 commit comments