Skip to content

Commit c6d56e7

Browse files
committed
designate type_predicate_annotation as its own rule
1 parent f80e913 commit c6d56e7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

common/corpus/types.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,11 @@ function isT(t: T): t is T {
736736
(required_parameter
737737
(identifier)
738738
(type_annotation (type_identifier))))
739-
(type_predicate
740-
(identifier)
741-
(type_identifier))
742-
(statement_block (return_statement (true))))
743-
)
739+
(type_predicate_annotation
740+
(type_predicate
741+
(identifier)
742+
(type_identifier)))
743+
(statement_block (return_statement (true)))))
744744

745745
==================================
746746
Tuple types

common/define-grammar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ module.exports = function defineGrammar(dialect) {
551551
$._type
552552
),
553553

554+
type_predicate_annotation: $ => seq(
555+
seq(':', $.type_predicate)
556+
),
557+
554558
type_query: $ => prec(PREC.TYPEOF, seq(
555559
'typeof',
556560
choice($.identifier, $.nested_identifier)
@@ -643,7 +647,7 @@ module.exports = function defineGrammar(dialect) {
643647
field('type_parameters', optional($.type_parameters)),
644648
field('parameters', $.formal_parameters),
645649
field('return_type', optional(
646-
choice($.type_annotation, $.asserts, seq(':', $.type_predicate))
650+
choice($.type_annotation, $.asserts, $.type_predicate_annotation)
647651
))
648652
),
649653

0 commit comments

Comments
 (0)