-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
XState version
XState version 5
Description
function test(event: InspectionEvent) {
assertEvent(event, '@xstate.event');
// eslint-disable-next-line no-console
console.log(event.event);
}
function test2<TEVENT extends InspectionEvent>(event: TEVENT) {
assertEvent(event, '@xstate.event');
// eslint-disable-next-line no-console
console.log(event.event);
}test2 results in a type error:

Expected result
no error, asserts works as expected
Actual result
error, cannot use assertEvent with generics.
Reproduction
https://codesandbox.io/p/devbox/nifty-cloud-wnzqnr
Additional context
I was able to avoid the typing issue by doing this, but I'm not sure if there's a better option:
function test2<TEVENT extends InspectionEvent>(eventP: TEVENT) {
const event: InspectionEvent = eventP;
assertEvent(event, '@xstate.event');
// eslint-disable-next-line no-console
console.log(event.event);
}Reactions are currently unavailable