Skip to content

Commit 6d2c003

Browse files
Only count singleton unit types.
1 parent d35cfc1 commit 6d2c003

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11976,22 +11976,20 @@ namespace ts {
1197611976
bestMatch = target;
1197711977
matchingCount = Infinity;
1197811978
}
11979-
else if (isLiteralType(overlap)) {
11979+
else if (overlap.flags & TypeFlags.Union) {
1198011980
// We only want to account for literal types otherwise.
1198111981
// If we have a union of index types, it seems likely that we
1198211982
// needed to elaborate between two generic mapped types anyway.
11983-
if (overlap.flags & TypeFlags.Union) {
11984-
const len = length(filter((overlap as UnionType).types, isUnitType));
11985-
if (len >= matchingCount) {
11986-
bestMatch = target;
11987-
matchingCount = len;
11988-
}
11989-
}
11990-
else if (1 >= matchingCount) {
11983+
const len = length(filter((overlap as UnionType).types, isUnitType));
11984+
if (len >= matchingCount) {
1199111985
bestMatch = target;
11992-
matchingCount = 1;
11986+
matchingCount = len;
1199311987
}
1199411988
}
11989+
else if (isUnitType(overlap) && 1 >= matchingCount) {
11990+
bestMatch = target;
11991+
matchingCount = 1;
11992+
}
1199511993
}
1199611994
return bestMatch;
1199711995
}

0 commit comments

Comments
 (0)