ts-type-forge
    Preparing search index...
    MutableMaxLengthArray: Mutable<readonly Elm[]> & TSTypeForgeInternals_BrandEncapsulated<
        Readonly<{ MaxLength: UintRangeInclusive<0, MaxLength> }>,
    >

    Mutable counterpart of MaxLengthArray: a branded mutable array type for arrays with at most MaxLength elements.

    Identical to MaxLengthArray except that the structural part is a mutable Elm[] instead of readonly Elm[], so elements can be reassigned. The brand is the same, so a MutableMaxLengthArray<M, Elm> is assignable to MaxLengthArray<M, Elm>.

    Note that the MaxLength constraint is not enforced under mutation: pushing additional elements past the bound is not a type error (as with any mutable array whose length is tracked only in the brand).

    Type Parameters

    • MaxLength extends SupportedLength

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

    • Elm = unknown

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

    const tags = ['a', 'b', 'c'] as unknown as MutableMaxLengthArray<8, string>;

    tags[0] = 'z'; // OK — elements are mutable
    const relaxed: MaxLengthArray<16, string> = tags; // OK (8 <= 16)
    // const strict: MutableMaxLengthArray<2, string> = tags; // Error! (8 > 2)