github statelyai/xstate xstate@5.3.0

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
11 months ago

Minor Changes

  • #4547 8e8d2ba38 Thanks @davidkpiano! - Add assertEvent(...) to help provide strong typings for events that can't be easily inferred, such as events in entry and exit actions, or in invoke.input.

    The assertEvent(event, 'someType') function will throw if the event is not the expected type. This ensures that the event is guaranteed to have that type, and assumes that the event object has the expected payload (naturally enforced by TypeScript).

    // ...
    entry: ({ event }) => {
      assertEvent(event, 'greet');
      // event is { type: 'greet'; message: string }
    
      assertEvent(event, ['greet', 'notify']);
      // event is { type: 'greet'; message: string }
      // or { type: 'notify'; message: string; level: 'info' | 'error' }
    },
    exit: ({ event }) => {
      assertEvent(event, 'doNothing');
      // event is { type: 'doNothing' }
    }

Patch Changes

  • #4586 97f1cbd5f Thanks @Andarist! - Fixed an issue with ancestors of the default history target that lie outside of the transition domain being incorrectly entered.

Don't miss a new xstate release

NewReleases is sending notifications on new releases.