ts-type-forge
    Preparing search index...

    Type Alias NonEmptyArray<A>

    NonEmptyArray: MinLengthArray<1, A>

    Represents a readonly array that is guaranteed to have at least one element.

    Brand-based alias of MinLengthArray<1, A>: unlike the structural NonEmptyTuple, the non-emptiness is encoded in the brand, so type-checking cost stays essentially independent of the size of A. Use NonEmptyTuple instead when a purely structural check is needed (e.g. T extends NonEmptyTuple<unknown>).

    Type Parameters

    • A

      The type of elements in the array.

    type NA = NonEmptyArray<number>; // MinLengthArray<1, number>
    const head = (arr: NA): number => arr[0]; // OK — no `undefined`