From a0c5608770b911d357c745f4842e03b408a135fe Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 09:44:24 -0700 Subject: [PATCH] Update comment --- src/compiler/checker.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7dbd6c1ab8b..09402b94119 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8538,9 +8538,10 @@ namespace ts { } } // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, narrow to whichever of the target type or the candidate type that is assignable - // to the other. Otherwise, the types are completely unrelated, so narrow to an intersection - // of the two types. + // Otherwise, if the target type is assignable to the candidate type, keep the target type. + // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate + // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the + // two types. const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, targetType) ? candidate : isTypeAssignableTo(type, candidate) ? type :