Skip to content

Version Packages (alpha) - #5616

Merged
davidkpiano merged 1 commit into
nextfrom
changeset-release/next
Jul 31, 2026
Merged

Version Packages (alpha)#5616
davidkpiano merged 1 commit into
nextfrom
changeset-release/next

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or setup this action to publish automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to next, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

next is currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, run changeset pre exit on next.

⚠️⚠️⚠️⚠️⚠️⚠️

Releases

xstate@6.0.0-alpha.26

Patch Changes

  • d46fbd2: Delayed transitions (onTimeout and after) and error transitions (onError) in machines created with setup({ states }) now type the context patch against the target state's context schema, matching the behavior of on: transitions. Previously, a cross-state context patch that was valid at runtime failed to typecheck:

    const machine = setup({
      schemas: {
        context: z.object({ reason: z.union([z.literal('timeout'), z.null()]) })
      },
      states: {
        running: { schemas: { context: z.object({ reason: z.null() }) } },
        expired: {
          schemas: { context: z.object({ reason: z.literal('timeout') }) }
        }
      }
    }).createMachine({
      context: { reason: null },
      initial: 'running',
      states: {
        running: {
          timeout: 5000,
          // Previously a type error; now checked against `expired`'s context
          onTimeout: () => ({
            target: 'expired',
            context: { reason: 'timeout' as const }
          })
        },
        expired: { type: 'final' }
      }
    });
  • d9d9e29: Per-state schemas declared in setup({ states }) are now available on the compiled machine's state nodes via machine.states.X.schemas, so tooling (e.g. per-state snapshot validators) can be derived from the machine alone. Previously they were only accessible on the setup return value.

    import { setup, types } from 'xstate';
    
    const machine = setup({
      states: {
        running: {
          schemas: { context: types<{ startedAt: number }>() }
        }
      }
    }).createMachine({
      initial: 'running',
      states: {
        running: {}
      }
    });
    
    machine.states.running.schemas?.context; // the schema declared in setup
  • 7da1486: Transition arrays are no longer accepted by the v6 createMachine(...) authoring API. Use a transition function to select among targets:

    createMachine({
      always: ({ context }) => {
        if (context.hour < 12) return { target: 'morning' };
        return { target: 'afternoon' };
      }
    });

    Serialized transition arrays remain supported by createMachineFromConfig(...).

@github-actions
github-actions Bot force-pushed the changeset-release/next branch from ab5b3b9 to f5c5328 Compare July 31, 2026 17:50
@davidkpiano
davidkpiano merged commit 4566b69 into next Jul 31, 2026
1 check passed
@davidkpiano
davidkpiano deleted the changeset-release/next branch July 31, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant