From 0f90d880b47381698dc66aa6ef97a372e5a2e0ee Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 10 Sep 2016 07:13:57 -0700 Subject: [PATCH] Preserve type parameter types in narrowing --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 79488b7b546..98a26fb0b33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8682,7 +8682,7 @@ namespace ts { // 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 : + return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : isTypeAssignableTo(candidate, targetType) ? candidate : getIntersectionType([type, candidate]);