Patch Changes
-
#5827
9b3a88fThanks @AlexRixten! - fix(core): fixassertEventnarrowing when the event type is behind a generic type parameterPreviously, calling
assertEventinside 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 oneventafterward would fail to type-check with a "Property does not exist" error. This is now fixed -assertEventnarrows generic event parameters the same way it narrows concrete ones, while still rejecting invalid event descriptors at compile time.assertEventalso keeps narrowing events whosetypefield 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 bothFEEDBACKandFEEDBACK.GOOD, so accessing a payload specific toFEEDBACK.GOODrequires further narrowing. This also applies toExtractEventand event types inferred for partial wildcard transitions.