xstate
5.33.4 · 7 Nov 2026MIT9M / weekRepositoryHomepagenpmAtom feed
4.38.3 is the newest release of 4.x.
In short
1 new6 fixed
Release note
Patch Changes
Widened the *From utility types to allow extracting from factory functions.
This allows for:
const makeMachine = () => createMachine({}); type Interpreter = InterpreterFrom<typeof makeMachine>; type Actor = ActorRefFrom<typeof makeMachine>; type Context = ContextFrom<typeof makeMachine>; type Event = EventsFrom<typeof makeMachine>;This also works for models, behaviours, and other actor types.
The previous method for doing this was a good bit more verbose:
const makeMachine = () => createMachine({}); type Interpreter = InterpreterFrom<ReturnType<typeof machine>>;The custom
.toString()method on action objects is now removed which improves performance in larger applications (see #2488 for more context).The
contextproperty has been removed fromStateNodeConfig, as it has never been allowed, nor has it ever done anything. The previous typing was unsafe and allowedcontextto be specified on nested state nodes:createMachine({ context: { /* ... */ }, // ✅ This is allowed initial: 'inner', states: { inner: { context: { /* ... */ } // ❌ This will no longer compile } } });A race condition occurred when a child service is immediately stopped and the parent service tried to remove it from its undefined state (during its own initialization). This has been fixed, and the race condition no longer occurs. See this issue for details.
Adjusted TS type definitions of the
withContextandwithConfigmethods so that they accept "lazy context" now.Example:
const copy = machine.withContext(() => ({ ref: spawn(() => {}) }));Fixed an issue with
state.hasTag('someTag')crashing when thestatewas rehydrated.Add utility type
EmittedFrom<T>that extractsEmittedtype from any type which can emit data
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.