Type Alias Immutable<T>

Immutable<T>: Omit<Const<T>, `do${Capitalize<string>}` | `set${Capitalize<string>}` | "assign">

Creates an immutable type that omits methods that signal modification of the object such as doAdd or setValues. Omitted perfixes are do*** and set***. All fields on the class become readonly on the resulting type and the mutable type cannot be assigned to the immutable type.

Type Parameters

  • T

It is important the type T type follows the convention that all methods that modify the object are prefixed with do*** or set***. Otherwise, the immutable contract is violated and the type can still mutate by calling methods that modify the properties internally.