mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 14:34:35 -06:00
Defer reduction of identical function types in unions and intersections
This commit is contained in:
parent
45101491c0
commit
059fcc9aa9
@ -8691,10 +8691,7 @@ namespace ts {
|
||||
const len = typeSet.length;
|
||||
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
|
||||
if (index < 0) {
|
||||
if (!(flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
|
||||
type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) {
|
||||
typeSet.splice(~index, 0, type);
|
||||
}
|
||||
typeSet.splice(~index, 0, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8710,15 +8707,6 @@ namespace ts {
|
||||
return includes;
|
||||
}
|
||||
|
||||
function containsIdenticalType(types: ReadonlyArray<Type>, type: Type) {
|
||||
for (const t of types) {
|
||||
if (isTypeIdenticalTo(t, type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSubtypeOfAny(source: Type, targets: ReadonlyArray<Type>): boolean {
|
||||
for (const target of targets) {
|
||||
if (source !== target && isTypeSubtypeOf(source, target) && (
|
||||
@ -8899,10 +8887,7 @@ namespace ts {
|
||||
if (flags & TypeFlags.AnyOrUnknown) {
|
||||
if (type === wildcardType) includes |= TypeFlags.Wildcard;
|
||||
}
|
||||
else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type) &&
|
||||
!(flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
|
||||
type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) &&
|
||||
containsIdenticalType(typeSet, type))) {
|
||||
else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type)) {
|
||||
typeSet.push(type);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user