do not apply subtype reduction if type set contains enum literals fro… (#11368)

* do not apply subtype reduction if type set contains enum literals from the same enum

* do not re-read symbol for the first enum

* addressed PR feedback
This commit is contained in:
Vladimir Matveev authored and GitHub committed 2016-10-04 16:32:16 -07:00
1 parent f4dc11427f
commit ebb17e8019
5 files changed
+23108

No files matched your search

+19
View File
@@ -5446,7 +5446,26 @@ namespace ts {
return false;
}
function isSetOfLiteralsFromSameEnum(types: TypeSet): boolean {
const first = types[0];
if (first.flags & TypeFlags.EnumLiteral) {
const firstEnum = getParentOfSymbol(first.symbol);
for (let i = 1; i < types.length; i++) {
const other = types[i];
if (!(other.flags & TypeFlags.EnumLiteral) || (firstEnum !== getParentOfSymbol(other.symbol))) {
return false;
}
}
return true;
}
return false;
}
function removeSubtypes(types: TypeSet) {
if (types.length === 0 || isSetOfLiteralsFromSameEnum(types)) {
return;
}
let i = types.length;
while (i > 0) {
i--;
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff