Type Alias ReadonlyDeep<T>

ReadonlyDeep<T>: T extends Primitive
    ? T
    : {
        readonly [K in keyof T]: ReadonlyDeep<T[K]>
    }

Transforms a JSON-compatible type T such that it and any nested arrays or basic objects are read-only.

Warnings:

  • Instances of most classes could still be modified via methods, aside from built-in Arrays, which are transformed to ReadonlyArrays with no mutator methods.
  • This only affects static type-checking and is not a guarantee of run-time immutability. Values with this type could still be modified if casted to any, passed into a function with an any signature, or by untyped JavaScript.

Use deepCopy(value) to get a fully mutable copy of a ReadonlyDeep.

Type Parameters

  • T