Type alias Immutable<T>

Immutable<T>: T extends _ImmutablePrimitive
    ? T
    : T extends (infer Value)[]
        ? ReadonlyArray<Immutable<Value>>
        : T extends Map<infer Key, infer Value>
            ? ReadonlyMap<Immutable<Key>, Immutable<Value>>
            : T extends Set<infer Value>
                ? ReadonlySet<Immutable<Value>>
                : {
                    readonly [Key in keyof T]: Immutable<T[Key]>
                }

An object that is recursively immutable. This type statically guards against modifying objects that should never be modified. Obviously, objects can always be changed at runtime.

Type Parameters

  • T

Generated using TypeDoc