Skip to content

xstate@5.33.4

Latest

Choose a tag to compare

@github-actions github-actions released this 07 Nov 19:08
· 609 commits to next since this release
bd77717

Patch Changes

  • #5827 9b3a88f Thanks @AlexRixten! - fix(core): fix assertEvent narrowing when the event type is behind a generic type parameter

    Previously, calling assertEvent inside a function whose event parameter was typed with a generic (e.g. function f<TEvent extends SomeEventUnion>(event: TEvent)) would compile, but every property access on event afterward would fail to type-check with a "Property does not exist" error. This is now fixed - assertEvent narrows generic event parameters the same way it narrows concrete ones, while still rejecting invalid event descriptors at compile time.

    assertEvent also keeps narrowing events whose type field is a union of literals (e.g. { type: 'a' | 'b'; value: string }) when asserting one of those literals, for both concrete and generic event parameters.

    Partial wildcard descriptors now preserve the bare prefix event in the narrowed type, matching runtime behavior. For example, assertEvent(event, 'FEEDBACK.*') keeps both FEEDBACK and FEEDBACK.GOOD, so accessing a payload specific to FEEDBACK.GOOD requires further narrowing. This also applies to ExtractEvent and event types inferred for partial wildcard transitions.