ts-type-forge
    Preparing search index...
    MutableMinLengthArray: MutableMinLengthTuple<ClampToPrefixCap<MinLength>, Elm> & TSTypeForgeInternals_BrandEncapsulated<
        Readonly<{ MinLength: MinLengthTuple<MinLength, 0> }>,
    >

    Mutable counterpart of MinLengthArray: a branded mutable array type for arrays with at least MinLength elements.

    Identical to MinLengthArray except that the clamped structural prefix is mutable (MutableMinLengthTuple instead of MinLengthTuple), so elements can be reassigned. The brand is the same, so a MutableMinLengthArray<M, Elm> is assignable to MinLengthArray<M, Elm>.

    This is the mutable, brand-based counterpart of the structural tuple-based MutableMinLengthTuple; type-checking cost stays essentially independent of the size of Elm and of the bound.

    Type Parameters

    • MinLength extends SupportedLength

      The minimum number of elements (inclusive). Must be a non-negative integer literal.

    • Elm = unknown

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

    const history = [0, 1, 2, 3] as unknown as MutableMinLengthArray<3, number>;

    history[0] = 10; // OK — elements are mutable
    const first: number = history[0]; // OK — no `undefined` below min(N, 10)
    const readonlyView: MinLengthArray<3, number> = history; // OK
    // const longer: MutableMinLengthArray<5, number> = history; // Error! (3 < 5)