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.
This commit is contained in:
Daniel Rosenwasser 2015-09-15 16:40:33 -07:00
parent b7c399cbbc
commit 61594d893e

View File

@ -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);