8000 Amend signature relation for when two signatures both return predicat… · prmdeveloper/TypeScript@61594d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61594d8

Browse files
Amend signature relation for when two signatures both return predicate types.
Consider signatures related if they are type predicates where the predicate's type in the source is a subtype of the predicate's type in the target.
1 parent b7c399c commit 61594d8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5200,7 +5200,7 @@ namespace ts {
52005200
let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex;
52015201
let hasDifferentTypes: boolean;
52025202
if (hasDifferentParameterIndex ||
5203-
(hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) {
5203+
(hasDifferentTypes = !isTypeSubtypeOf(source.typePredicate.type, target.typePredicate.type))) {
52045204

52055205
if (reportErrors) {
52065206
let sourceParamText = source.typePredicate.parameterName;
@@ -5234,7 +5234,9 @@ namespace ts {
52345234
}
52355235

52365236
let targetReturnType = getReturnTypeOfSignature(target);
5237-
if (targetReturnType === voidType) return result;
5237+
if (targetReturnType === voidType) {
5238+
return result;
5239+
}
52385240
let sourceReturnType = getReturnTypeOfSignature(source);
52395241

52405242
return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors);

0 commit comments

Comments
 (0)
0