Skip to content

Commit 46e9c43

Browse files
committed
Merge branch 'master' into object_is
2 parents 3e83446 + 22167c2 commit 46e9c43

File tree

6 files changed

+222794
-224132
lines changed

6 files changed

+222794
-224132
lines changed

common/corpus/types.txt

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ type T = typeof array[number];
767767
(type_alias_declaration (type_identifier)
768768
(intersection_type (index_type_query (type_identifier)) (type_identifier)))
769769
(type_alias_declaration (type_identifier)
770-
(type_query (subscript_expression (identifier) (predefined_type)))))
770+
(lookup_type (type_query (identifier)) (predefined_type))))
771771

772772
=======================================
773773
Lookup types
@@ -1342,9 +1342,10 @@ type T = Foo<Bar<typeof bar["baz"]>>
13421342
(generic_type
13431343
(type_identifier)
13441344
(type_arguments
1345-
(type_query
1346-
(subscript_expression
1347-
(identifier)
1345+
(lookup_type
1346+
(type_query
1347+
(identifier))
1348+
(literal_type
13481349
(string
13491350
(string_fragment))))))))))
13501351

@@ -1431,3 +1432,33 @@ type Foo<T> = abstract new () => T;
14311432
---
14321433

14331434
(program (type_alias_declaration (type_identifier) (type_parameters (type_parameter (type_identifier))) (constructor_type (formal_parameters) (type_identifier))))
1435+
1436+
=========================
1437+
Indexed Access Precedence
1438+
=========================
1439+
1440+
// These should generate the same AST aside from the parenthesized_type node
1441+
type X1 = typeof Y[keyof typeof Z];
1442+
type X2 = (typeof Y)[keyof typeof Z];
1443+
1444+
---
1445+
1446+
(program
1447+
(comment)
1448+
(type_alias_declaration
1449+
(type_identifier)
1450+
(lookup_type
1451+
(type_query
1452+
(identifier))
1453+
(index_type_query
1454+
(type_query
1455+
(identifier)))))
1456+
(type_alias_declaration
1457+
(type_identifier)
1458+
(lookup_type
1459+
(parenthesized_type
1460+
(type_query
1461+
(identifier)))
1462+
(index_type_query
1463+
(type_query
1464+
(identifier))))))

common/define-grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = function defineGrammar(dialect) {
4545
[$.readonly_type, $.pattern],
4646
[$.readonly_type, $.primary_expression],
4747
[$.type_query, $.subscript_expression, $.expression],
48+
[$.type_query, $._type_query_subscript_expression],
4849
[$.nested_type_identifier, $.generic_type, $._primary_type, $.lookup_type, $.index_type_query, $._type],
4950
[$.as_expression, $._primary_type],
5051
[$._type_query_member_expression, $.member_expression],

tsx/src/grammar.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10814,6 +10814,16 @@
1081410814
"name": "expression"
1081510815
}
1081610816
],
10817+
[
10818+
{
10819+
"type": "SYMBOL",
10820+
"name": "type_query"
10821+
},
10822+
{
10823+
"type": "SYMBOL",
10824+
"name": "_type_query_subscript_expression"
10825+
}
10826+
],
1081710827
[
1081810828
{
1081910829
"type": "SYMBOL",

0 commit comments

Comments
 (0)