ts-type-forge
    Preparing search index...
    FixedLengthArray: BoundedLengthArray<Length, Length, Elm> & (
        Length extends UintRangeInclusive<0, StructuralPrefixCap>
            ? FixedLengthTuple<Length, Elm>
            : unknown
    )

    Branded readonly array type for arrays with exactly Length elements. Alias for BoundedLengthArray<Length, Length, Elm>.

    This is the brand-based, lightweight counterpart of the structural tuple-based FixedLengthTuple; type-checking cost stays essentially independent of the size of Elm. Prefer this type when Elm is a large type or the length is large.

    For Length <= 10, the structural part is additionally intersected with the exact tuple FixedLengthTuple<Length, Elm>, so length is the literal Length and in-range indexed access does not include undefined under noUncheckedIndexedAccess (and the type is assignable to FixedLengthTuple<Length, Elm>). For larger lengths only the clamped structural prefix inherited from MinLengthArray remains.

    Type Parameters

    • Length extends SupportedLength

      The exact number of elements. Must be a non-negative integer literal.

    • Elm = unknown

      The type of elements in the array (defaults to unknown).

    const rgb = [255, 128, 0] as unknown as FixedLengthArray<3, number>;

    const atMost5: MaxLengthArray<5, number> = rgb; // OK (3 <= 5)
    const nonEmpty: MinLengthArray<1, number> = rgb; // OK (3 >= 1)
    const red: number = rgb[0]; // OK — in-range indexed access (N <= 10)
    const len: 3 = rgb.length; // `length` is the literal N (N <= 10)
    // const rgba: FixedLengthArray<4, number> = rgb; // Error!