Type alias SizedTuple<T, N>

SizedTuple<T, N>: number extends N
    ? T[]
    : N extends 0
        ? []
        : N extends PositiveInteger<N>
            ? BuildSizedTuple<T, N>
            : never

Represents a tuple of size N, where N is a positive integer. The tuple's length is exactly N, with each element of the tuple being of type T.

Type Parameters

  • T

    The type of the elements in the tuple.

  • N extends number

    The desired length of the tuple.

Template: Acc

Accumulator type for recursive construction.

Example

SizedTuple<string, 3>; // Result: [string, string, string]
SizedTuple<number, 2>; // Result: [number, number]
SizedTuple<number, 0>; // Result: []

See

Tuple