ts-data-forge
    Preparing search index...
    • Casts an array to FixedLengthArray<0, E> after checking that it is empty.

      Arr.isEmpty narrows to that same type, so this is its cast counterpart — the length-0 specialization of asFixedLengthArray. Use this instead of writing xs as unknown as FixedLengthArray<0, E>: the length is verified at runtime, and the original array type is preserved via intersection.

      Type Parameters

      • Xs extends readonly unknown[]

        The input array type (tuple types are preserved).

      Parameters

      • xs: Xs

        The array to cast.

      Returns readonly Xs[number][] & Readonly<{ MaxLength: 0 }> & Readonly<
          {
              "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
          },
      > & Readonly<{ MinLength: readonly 0[] }> & readonly [] & Xs

      xs typed as FixedLengthArray<0, Xs[number]> & Xs.

      const nothing = Arr.asEmptyArray([]);

      const atMost5: MaxLengthArray<5, never> = nothing; // OK (0 <= 5)

      // Arr.asEmptyArray([1]); // throws TypeError

      If xs is not empty.