Skip to content

Commit 49cc3df

Browse files
committed
Merge remote-tracking branch 'resolritter/rework_typeof'
2 parents 8fe48c4 + 85cc247 commit 49cc3df

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

common/corpus/types.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,18 +668,33 @@ const repository = foo++!
668668
Type query and index type query types
669669
=======================================
670670

671-
type K1 = keyof Person;
672-
type K1 = typeof Person;
671+
type T = keyof Person;
672+
type T = keyof Person.P;
673+
type T = keyof Person<P>;
674+
675+
type T = typeof Person;
676+
type T = typeof Person.P;
677+
type T = typeof Person<P>;
678+
679+
type T = keyof typeof Person;
673680

674681
---
675682

676683
(program
677-
(type_alias_declaration
678-
(type_identifier)
684+
(type_alias_declaration (type_identifier)
679685
(index_type_query (type_identifier)))
680-
(type_alias_declaration
681-
(type_identifier)
682-
(type_query (identifier))))
686+
(type_alias_declaration (type_identifier)
687+
(index_type_query (nested_type_identifier (identifier) (type_identifier))))
688+
(type_alias_declaration (type_identifier)
689+
(index_type_query (generic_type (type_identifier) (type_arguments (type_identifier)))))
690+
(type_alias_declaration (type_identifier)
691+
(type_query (identifier)))
692+
(type_alias_declaration (type_identifier)
693+
(type_query (nested_identifier (identifier) (identifier))))
694+
(type_alias_declaration (type_identifier)
695+
(type_query (generic_type (type_identifier) (type_arguments (type_identifier)))))
696+
(type_alias_declaration (type_identifier)
697+
(index_type_query (type_query (identifier)))))
683698

684699
=======================================
685700
Lookup types

common/define-grammar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ module.exports = function defineGrammar(dialect) {
591591

592592
type_query: $ => prec(PREC.TYPEOF, seq(
593593
'typeof',
594-
choice($.identifier, $.nested_identifier)
594+
choice($.identifier, $.nested_identifier, $.generic_type)
595595
)),
596596

597597
index_type_query: $ => seq(
598598
'keyof',
599-
prec.left(PREC.DECLARATION, choice($.generic_type, $._type_identifier, $.nested_type_identifier))
599+
prec.left(PREC.DECLARATION, choice($.generic_type, $._type_identifier, $.nested_type_identifier, $.type_query))
600600
),
601601

602602
lookup_type: $ => prec(PREC.ARRAY_TYPE, seq(

0 commit comments

Comments
 (0)