mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Preserve type parameter types in narrowing
This commit is contained in:
parent
2305c68560
commit
0f90d880b4
@ -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]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user