The contract a state type is held to, as an immutable object combining:
Version Data - Data properties describing the current state
Transition Methods - Methods with signature like transition(...inputs): this that take inputs and generate
a new immutable state with updated version data
Type Parameters
T
The state type being constrained
Remarks
Declaration
State types are declared as plain interfaces or object types, with no base to extend: they are admitted wherever
this module declares a state type parameter, bound as T extends State<T>
A method returning anything other than the state itself is refused by the compiler where the state type is
supplied, as are non-object types
Read-only data properties are a contract the compiler cannot enforce, since readonly modifiers don't take part
in assignability
Immutability
States are immutable: members are read-only, so a write is refused by the compiler rather than throwing at run
time, and every change goes through a transition method
Transition methods return new immutable States
Transitions
Transition methods can be destructured and called independently (e.g., const { increment } = state; increment();)
State contract.
The contract a state type is held to, as an immutable object combining:
transition(...inputs): thisthat take inputs and generate a new immutable state with updated version data