mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 07:13:43 -05:00
Merge pull request #11374 from Microsoft/port-11368
ports #11398 in release-2.0.5
This commit is contained in:
@@ -5386,7 +5386,26 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeSubtypes(types: Type[]) {
|
||||
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--;
|
||||
|
||||
4113
tests/baselines/reference/enumLiteralsSubtypeReduction.js
Normal file
4113
tests/baselines/reference/enumLiteralsSubtypeReduction.js
Normal file
File diff suppressed because it is too large
Load Diff
7693
tests/baselines/reference/enumLiteralsSubtypeReduction.symbols
Normal file
7693
tests/baselines/reference/enumLiteralsSubtypeReduction.symbols
Normal file
File diff suppressed because it is too large
Load Diff
9229
tests/baselines/reference/enumLiteralsSubtypeReduction.types
Normal file
9229
tests/baselines/reference/enumLiteralsSubtypeReduction.types
Normal file
File diff suppressed because it is too large
Load Diff
2054
tests/cases/compiler/enumLiteralsSubtypeReduction.ts
Normal file
2054
tests/cases/compiler/enumLiteralsSubtypeReduction.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user