PokéRogue
    Preparing search index...

    Type Alias CollapseRestElement<TArray>

    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.

    Type Parameters

    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.

    // `exactOptionalPropertyTypes` enabled
    type A = CollapseRestElement<[string?, string?, ...number[]]>;
    //=> [string, string, number]

    // `exactOptionalPropertyTypes` disabled
    type B = CollapseRestElement<[string?, string?, ...number[]]>;
    //=> [string | undefined, string | undefined, number]