type A = CollapseRestElement<[string, string, ...number[]]>;
//=> [string, string, number]
type B = CollapseRestElement<[...string[], number, number]>;
//=> [string, number, number]
type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
//=> [string, string, number | bigint]
type D = CollapseRestElement<[string, number]>;
//=> [string, number]
Note: Optional modifiers (?) are removed from elements unless the exactOptionalPropertyTypes compiler option is disabled. When disabled, there's an additional | undefined for optional elements.
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.