Skip to content

xstate@5.3.0

Compare
Choose a tag to compare
@github-actions github-actions released this 13 Dec 17:53
· 138 commits to main since this release
260f4fd

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.