mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Add single-element fastpath to getSupertypeOrUnion (#43934)
This commit is contained in:
parent
6f8c3b0c99
commit
84da19efc8
@ -19954,6 +19954,9 @@ namespace ts {
|
||||
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
||||
// right is a supertype.
|
||||
function getSupertypeOrUnion(types: Type[]): Type {
|
||||
if (types.length === 1) {
|
||||
return types[0];
|
||||
}
|
||||
return literalTypesWithSameBaseType(types) ?
|
||||
getUnionType(types) :
|
||||
reduceLeft(types, (s, t) => isTypeSubtypeOf(s, t) ? t : s)!;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user