xstate
5.33.4 · 7 Nov 2026MIT9M / weekRepositoryHomepagenpmAtom feed
4.38.3 is the newest release of 4.x.
In short
3 new1 fixed
Release note
Minor Changes
You can now know if an event will cause a state change by using the new
state.can(event)method, which will returntrueif an interpreted machine will "change" the state when sent theevent, orfalseotherwise:const machine = createMachine({ initial: 'inactive', states: { inactive: { on: { TOGGLE: 'active' } }, active: { on: { DO_SOMETHING: { actions: ['something'] } } } } }); const state = machine.initialState; state.can('TOGGLE'); // true state.can('DO_SOMETHING'); // false // Also takes in full event objects: state.can({ type: 'DO_SOMETHING', data: 42 }); // falseA state is considered "changed" if any of the following are true:
its
state.valuechangesthere are new
state.actionsto be executedits
state.contextchanges
See
state.changed(documentation) for more details.
Patch Changes
A regression was fixed where actions were being typed as
neverif events were specified increateModel(...)but not actions:const model = createModel( {}, { events: {} } ); model.createMachine({ // These actions will cause TS to not compile entry: 'someAction', exit: { type: 'someObjectAction' } });
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.