Skip to content

Commit 8fe48c4

Browse files
committed
Merge remote-tracking branch 'resolritter/this_in_type_predicate'
2 parents 2097b39 + 35f6be1 commit 8fe48c4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

common/corpus/types.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,10 @@ Assertion functions checking a type
745745
function f(x: any): asserts x is number {
746746
}
747747

748+
class Foo<T> {
749+
test(): this is T {}
750+
}
751+
748752
function isT(t: T): t is T {
749753
return true
750754
}
@@ -759,6 +763,18 @@ function isT(t: T): t is T {
759763
(identifier) (type_annotation (predefined_type))))
760764
(asserts (type_predicate (identifier) (predefined_type)))
761765
(statement_block))
766+
(class_declaration
767+
(type_identifier)
768+
(type_parameters (type_parameter (type_identifier)))
769+
(class_body
770+
(method_definition
771+
(property_identifier)
772+
(formal_parameters)
773+
(type_predicate_annotation
774+
(type_predicate
775+
(this)
776+
(type_identifier)))
777+
(statement_block))))
762778
(function_declaration
763779
(identifier)
764780
(formal_parameters

common/define-grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ module.exports = function defineGrammar(dialect) {
580580
),
581581

582582
type_predicate: $ => seq(
583-
$.identifier,
583+
choice($.identifier, $.this),
584584
'is',
585585
$._type
586586
),

0 commit comments

Comments
 (0)