mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
check return type of this type predicates (#57341)
This commit is contained in:
@@ -736,6 +736,7 @@ import {
|
||||
isThisInTypeQuery,
|
||||
isThisProperty,
|
||||
isThisTypeParameter,
|
||||
isThisTypePredicate,
|
||||
isTransientSymbol,
|
||||
isTupleTypeNode,
|
||||
isTypeAlias,
|
||||
@@ -21217,7 +21218,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (sourceTypePredicate) {
|
||||
result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
|
||||
}
|
||||
else if (isIdentifierTypePredicate(targetTypePredicate)) {
|
||||
else if (isIdentifierTypePredicate(targetTypePredicate) || isThisTypePredicate(targetTypePredicate)) {
|
||||
if (reportErrors) {
|
||||
errorReporter!(Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ export class LineNode implements LineCollection {
|
||||
if (children.length) this.updateCounts();
|
||||
}
|
||||
|
||||
isLeaf() {
|
||||
isLeaf(): this is LineLeaf {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -839,7 +839,7 @@ export class LineLeaf implements LineCollection {
|
||||
constructor(public text: string) {
|
||||
}
|
||||
|
||||
isLeaf() {
|
||||
isLeaf(): this is LineLeaf {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user