From 61594d893e5b54ef299ebe91f64174bc8c8f501d Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 15 Sep 2015 16:40:33 -0700 Subject: [PATCH] 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. --- src/compiler/checker.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f2d1f070b2d..a6f7f8477d4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5200,7 +5200,7 @@ namespace ts { let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; let hasDifferentTypes: boolean; if (hasDifferentParameterIndex || - (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { + (hasDifferentTypes = !isTypeSubtypeOf(source.typePredicate.type, target.typePredicate.type))) { if (reportErrors) { let sourceParamText = source.typePredicate.parameterName; @@ -5234,7 +5234,9 @@ namespace ts { } let targetReturnType = getReturnTypeOfSignature(target); - if (targetReturnType === voidType) return result; + if (targetReturnType === voidType) { + return result; + } let sourceReturnType = getReturnTypeOfSignature(source); return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors);