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

_<A, N, Fail, Upper, Lower>: IsEqual<A["length"], 0, Fail, IsInteger<N, {
    $else: IsAny<N, {
        $else: IsNumber<N, NumberPlus.IsNumber.$Branch<{
                exact: true;
            }>> extends infer R
            ? R extends $Then
                ? N
                : never
            : never;
        $then: number;
    }>;
    $then: IsNumber<A["length"], NumberPlus.IsNumber.$Branch<{
            exact: true;
        }>> extends infer R
        ? R extends $Then
            ? N
            : R extends $Else
                ? IsNegative<N, {
                    $else: GreaterThan<(...)[(...)], N> extends true
                        ? N
                        : Upper;
                    $then: GreaterThan<Abs<(...)>, (...)[(...)]> extends true
                        ? Lower
                        : Subtract<(...)[(...)], Abs<(...)>>;
                }>
                : never
        : never;
}>>

Type Parameters

  • A extends readonly unknown[]
  • N extends number
  • Fail = never
  • Upper = A["length"]
  • Lower = 0