Open taraldr opened 3 months ago
XState version 5
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:
()
(_)
(_, params: { some: string )})
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
No type error.
Type error.
https://stackblitz.com/edit/vitejs-vite-dwgz2w?file=src%2Fmain.ts&view=editor
v5.16.0
Also observing the same behaviour if you have:
Repro: https://stackblitz.com/edit/vitejs-vite-kemb2g?file=src%2Fmain.ts&view=editor
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:
()
vs(_)
(_, params: { some: string )})
This results in a typescript error on the action along the lines of, indicating that parameter type inference broke.
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-dwgz2w?file=src%2Fmain.ts&view=editor
Additional context
v5.16.0