Bug: [Typescript] Failing to declare first parameter of guard breaks type inference in enqueueActions if another guard accepts dynamic parameters
Author: taraldrCreated Aug 1, 2024Updated Oct 17, 2025
Labelsbug
XState version
XState version 5
Description
Hi, love XState - just ported my teams typescript clients to XState, and came across this bug I think you might find interesting.
Parameter inference seems to break if you have:
- A guard which fails to declare the first parameter -
()vs(_) - Another guard which uses the second parameter -
(_, params: { some: string )}) - An action using enqueueActions
This results in a typescript error on the action along the lines of, indicating that parameter type inference broke.
Type '{ type: "guardWithParams"; params: unknown; }' is not assignable to type '{ type: "guardWithParams"; params: { some: string; }; }'.Workaround is always declaring the first parameter of all guards, even if unused.
@Andarist
Expected result
No type error.
Actual result
Type error.
Reproduction
https://stackblitz.com/edit/vitejs-vite-iqaqw4d9?file=src%2Fmain.ts
Additional context
v5.16.0
Source: statelyai/xstate