ts-type-forge
    Preparing search index...

    Type Alias ArrayAtLeastLen<N, Elm>

    ArrayAtLeastLen: readonly [...MakeTuple<Elm, N>, ...Elm[]]

    Creates a readonly array type that is guaranteed to have at least N elements of type Elm.

    Type Parameters

    • N extends number

      The minimum length of the array (must be a non-negative integer literal).

    • Elm

      The type of elements in the array.

    A readonly array type readonly [Elm, ..., Elm, ...Elm[]] with at least N elements.

    type AtLeast3Strings = ArrayAtLeastLen<3, string>; // readonly [string, string, string, ...string[]]
    const valid: AtLeast3Strings = ["a", "b", "c"];
    const alsoValid: AtLeast3Strings = ["a", "b", "c", "d"];
    // const invalid: AtLeast3Strings = ["a", "b"]; // Error