Skip to content

Commit 059fcc9

Browse files
committed
Defer reduction of identical function types in unions and intersections
1 parent 4510149 commit 059fcc9

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8691,10 +8691,7 @@ namespace ts {
86918691
const len = typeSet.length;
86928692
const index = len && type.id > typeSet[len - 1].id ? ~len : binarySearch(typeSet, type, getTypeId, compareValues);
86938693
if (index < 0) {
8694-
if (!(flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
8695-
type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && containsIdenticalType(typeSet, type))) {
8696-
typeSet.splice(~index, 0, type);
8697-
}
8694+
typeSet.splice(~index, 0, type);
86988695
}
86998696
}
87008697
}
@@ -8710,15 +8707,6 @@ namespace ts {
87108707
return includes;
87118708
}
87128709

8713-
function containsIdenticalType(types: ReadonlyArray<Type>, type: Type) {
8714-
for (const t of types) {
8715-
if (isTypeIdenticalTo(t, type)) {
8716-
return true;
8717-
}
8718-
}
8719-
return false;
8720-
}
8721-
87228710
function isSubtypeOfAny(source: Type, targets: ReadonlyArray<Type>): boolean {
87238711
for (const target of targets) {
87248712
if (source !== target && isTypeSubtypeOf(source, target) && (
@@ -8899,10 +8887,7 @@ namespace ts {
88998887
if (flags & TypeFlags.AnyOrUnknown) {
89008888
if (type === wildcardType) includes |= TypeFlags.Wildcard;
89018889
}
8902-
else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type) &&
8903-
!(flags & TypeFlags.Object && (<ObjectType>type).objectFlags & ObjectFlags.Anonymous &&
8904-
type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method) &&
8905-
containsIdenticalType(typeSet, type))) {
8890+
else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type)) {
89068891
typeSet.push(type);
89078892
}
89088893
}

0 commit comments

Comments
 (0)