diff --git a/lib/StateMachine.ts b/lib/StateMachine.ts index 507e0a3cc..b2ad91f03 100644 --- a/lib/StateMachine.ts +++ b/lib/StateMachine.ts @@ -1,5 +1,3 @@ -import type {ReadonlyDeep} from 'type-fest'; - /** * A directed transition graph keyed by state name. * Use `as const` when defining a graph so illegal transitions are caught at compile time. @@ -34,13 +32,13 @@ type TransitionsFrom { - /** The current state. Deeply readonly and owned by this state machine instance. */ - readonly state: ReadonlyDeep; + /** The current state. Owned by this state machine instance. */ + readonly state: Current; private readonly transitions: Graph; constructor(currentState: Current, transitions: Graph) { - this.state = currentState as ReadonlyDeep; + this.state = currentState; this.transitions = transitions; Object.freeze(this); } @@ -50,7 +48,7 @@ class StateMachine>(target: Target): StateMachine { - const validTargets = this.transitions[this.state as Current]; + const validTargets = this.transitions[this.state]; if (!validTargets?.includes(target)) { throw new Error(`Illegal transition from "${String(this.state)}" to "${String(target)}"`); }