mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 16:56:06 -05:00
Merge pull request #26143 from mattmccutchen/issue-26130
Have getAssignmentReducedType use the comparable relation instead of typeMaybeAssignableTo.
This commit is contained in:
@@ -13843,18 +13843,6 @@ namespace ts {
|
||||
return flow.id;
|
||||
}
|
||||
|
||||
function typeMaybeAssignableTo(source: Type, target: Type) {
|
||||
if (!(source.flags & TypeFlags.Union)) {
|
||||
return isTypeAssignableTo(source, target);
|
||||
}
|
||||
for (const t of (<UnionType>source).types) {
|
||||
if (isTypeAssignableTo(t, target)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove those constituent types of declaredType to which no constituent type of assignedType is assignable.
|
||||
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
||||
// we remove type string.
|
||||
@@ -13863,7 +13851,7 @@ namespace ts {
|
||||
if (assignedType.flags & TypeFlags.Never) {
|
||||
return assignedType;
|
||||
}
|
||||
const reducedType = filterType(declaredType, t => typeMaybeAssignableTo(assignedType, t));
|
||||
const reducedType = filterType(declaredType, t => isTypeComparableTo(assignedType, t));
|
||||
if (!(reducedType.flags & TypeFlags.Never)) {
|
||||
return reducedType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user