mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
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:
1 parent
f4dc11427f
commit
ebb17e8019
5 files changed
+23108
No files matched your search
@@ -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
Reference in new issue
Block a user