ts-type-forge
    Preparing search index...
    MutableFixedLengthArray: MutableBoundedLengthArray<Length, Length, Elm> & (
        Length extends UintRangeInclusive<0, StructuralPrefixCap>
            ? MutableFixedLengthTuple<Length, Elm>
            : unknown
    )

    Mutable counterpart of FixedLengthArray: a branded mutable array type for arrays with exactly Length elements. Alias for MutableBoundedLengthArray<Length, Length, Elm>.

    Identical to FixedLengthArray except that the structural part is mutable: for Length <= 10 it is intersected with the exact mutable tuple MutableFixedLengthTuple (so length is the literal Length, in-range indexed access does not include undefined under noUncheckedIndexedAccess, and elements can be reassigned); for larger lengths only the clamped mutable structural prefix inherited from MutableMinLengthArray remains. The brand is the same as FixedLengthArray, so a MutableFixedLengthArray<Length, Elm> is assignable to FixedLengthArray<Length, Elm>.

    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 MutableFixedLengthArray<3, number>;

    rgb[0] = 200; // OK — elements are mutable
    const len: 3 = rgb.length; // `length` is the literal N (N <= 10)
    const readonlyView: FixedLengthArray<3, number> = rgb; // OK
    // const rgba: MutableFixedLengthArray<4, number> = rgb; // Error!