Packages

xstate

5.33.4 · 7 Nov 2026MIT9M / weekRepositoryHomepagenpmAtom feed

Your version

4.29.0

27 Jan 2022Where it was published

4.38.3 is the newest release of 4.x.

In short

3 new1 fixed

Release note

Minor Changes

  • Using config.schema becomes the preferred way of "declaring" TypeScript generics with this release:

    createMachine({
        schema: {
            context: {} as { count: number },
            events: {} as { type: 'INC' } | { type: 'DEC' }
        }
    })

    This allows us to leverage the inference algorithm better and unlocks some exciting possibilities for using XState in a more type-strict manner.

  • Added the ability to tighten TS declarations of machine with generated metadata. This opens several exciting doors to being able to use typegen seamlessly with XState to provide an amazing typing experience.

    With the VS Code extension, you can specify a new attribute called tsTypes: {} in your machine definition:

    const machine = createMachine({
      tsTypes: {}
    });

    The extension will automatically add a type assertion to this property, which allows for type-safe access to a lot of XState's API's.

    ⚠️ This feature is in beta. Actions/services/guards/delays might currently get incorrectly annotated if they are called "in response" to always transitions or raised events. We are working on fixing this, both in XState and in the typegen.

Patch Changes

  • Added t(), which can be used to provide types for schema attributes in machine configs:

    import { t, createMachine } from 'xstate';
    
    const machine = createMachine({
      schema: {
        context: t<{ value: number }>(),
        events: t<{ type: 'EVENT_1' } | { type: 'EVENT_2' }>()
      }
    });
  • The repository links have been updated from github.com/davidkpiano to github.com/statelyai.

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.