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

_: IsEqual<
    A["length"],
    0,
    Fail,
    NumberPlus.IsInteger<
        N,
        {
            $else: IsAny<
                N,
                {
                    $else: NumberPlus.IsNumber<
                        N,
                        NumberPlus.IsNumber.$Branch<{ exact: true }>,
                    > extends infer R
                        ? R extends $Then ? N : never
                        : never;
                    $then: number;
                },
            >;
            $then: NumberPlus.IsNumber<
                A["length"],
                NumberPlus.IsNumber.$Branch<{ exact: true }>,
            > extends infer R
                ? R extends $Then
                    ? N
                    : R extends $Else
                        ? NumberPlus.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