type-plus
    Preparing search index...

    Type Alias IndexAt<A, N, Fail, Upper, Lower>

    IndexAt: IsNever<
        A,
        { $else: ArrayPlus.IndexAt._<A, N, Fail, Upper, Lower>; $then: Fail },
    >

    🦴 utilities

    Gets the normalized index to access the element of an array or tuple.

    Type Parameters

    • A extends readonly unknown[]
    • N extends number
    • Fail = never
    • Upper = A["length"]
    • Lower = 0
    type R = IndexAt<['a', 'b', 'c'], 2> // 2
    type R = IndexAt<['a', 'b', 'c'], -2> // 1

    type R = IndexAt<['a', 'b', 'c'], 3> // never
    type R = IndexAt<['a', 'b', 'c'], -4> // never