ts-type-forge
    Preparing search index...

    Type Alias ArrayElement<S>

    ArrayElement: S extends readonly (infer T)[] ? T : never

    Extracts the element type from a readonly array or tuple type S. If S is not an array or tuple type, it resolves to never.

    Type Parameters

    • S

      The array or tuple type.

    The type of the elements within the array/tuple.

    type StrElm = ArrayElement<string[]>; // string
    type NumElm = ArrayElement<readonly number[]>; // number
    type TupleElm = ArrayElement<[string, boolean]>; // string | boolean
    type NotArray = ArrayElement<{ a: number }>; // never