Skip to content

Commit ef17dc5

Browse files
authored
Merge pull request #11374 from Microsoft/port-11368
ports #11398 in release-2.0.5
2 parents 132d1da + 4f39a3b commit ef17dc5

File tree

5 files changed

+23109
-1
lines changed

5 files changed

+23109
-1
lines changed

src/compiler/checker.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5386,7 +5386,26 @@ namespace ts {
53865386
return false;
53875387
}
53885388

5389-
function removeSubtypes(types: Type[]) {
5389+
function isSetOfLiteralsFromSameEnum(types: TypeSet): boolean {
5390+
const first = types[0];
5391+
if (first.flags & TypeFlags.EnumLiteral) {
5392+
const firstEnum = getParentOfSymbol(first.symbol);
5393+
for (let i = 1; i < types.length; i++) {
5394+
const other = types[i];
5395+
if (!(other.flags & TypeFlags.EnumLiteral) || (firstEnum !== getParentOfSymbol(other.symbol))) {
5396+
return false;
5397+
}
5398+
}
5399+
return true;
5400+
}
5401+
5402+
return false;
5403+
}
5404+
5405+
function removeSubtypes(types: TypeSet) {
5406+
if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) {
5407+
return;
5408+
}
53905409
let i = types.length;
53915410
while (i > 0) {
53925411
i--;

0 commit comments

Comments
 (0)