utilitypes-ts
    Preparing search index...

    Type Alias MinLengthArray<T, N>

    MinLengthArray: [...Tuple<T, N>, ...T[]]

    Creates an array type with a minimum length of N.

    The first N elements are required, and any additional elements are optional and of the same type T.

    Type Parameters

    • T

      The element type

    • N extends number

      The minimum required length

    type Result = MinLengthArray<string, 2>;
    // ^?
    // [string, string, ...string[]]

    //@ts-expect-error - requires at least 2 elements
    const invalid: Result = ["hello"];