#5448·xstate

Bug: [5.25.0] typing issue when using assertEvent and generics

Author: jlowcsCreated Jan 15, 2026Updated Jan 24, 2026
Labelsbug

XState version

XState version 5

Description

typescript
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: Image

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:

typescript
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);
}