Release Notes
Minor Changes
c0c21d0: Add a path-bound overload to
setup(...).createStateConfig(path, config).When a state declares its own input schema, the anonymous
createStateConfig(config)form typesinputas a broad union across all states. This makes the resulting config incompatible with the specific state it's meant for — assigning it insidecreateMachineproduces a type error because the input types don't match.The new
createStateConfig(path, config)overload binds the config to a specific setup-declared state by dotted path (e.g.'loading'or'parent.child'). The addressed state's own input schema is used insideentry/exitargs, and bare transition targets are validated against the state's siblings.const s = setup({ states: { idle: {}, active: { schemas: { input: z.object({ userId: z.string() }) } } } }); // Before: anonymous form — `input` is typed broadly, and assigning this // config to the `active` state in createMachine fails with a type error. const active = s.createStateConfig({ entry: ({ input }) => { // input is not narrowed to { userId: string } } }); // After: path-bound form — `input` is narrowed to `active`'s own schema. const active = s.createStateConfig('active', { entry: ({ input }) => { input.userId; // string } }); // Works for nested states too: const child = s.createStateConfig('parent.child', { ... });
Patch Changes
8e3cce6: Fix
snapshot.matches(...)narrowing so repeated checks likesnapshot.matches('loaded') || snapshot.matches('failed')compile correctly, and makeStateFrom<typeof machine>preserve the machine's concrete state value.0c2a6e5: Fix function-syntax transitions not passing
inputto target state entry actions.on: { FETCH: ({ context, event }) => ({ target: 'fetching', input: { url: event.url, token: context.authToken } }); }Previously,
inputreturned from function-syntax transitions was silently ignored. Now it is correctly forwarded to the target state'sentryaction.