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.
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.