Closed FedericoBiccheddu closed 1 month ago
It works OK as intended, the input that you configure for your promise actor is its input - not the input given to the outer machine. Please take a look at this TS playground that, I hope, will help to clarify the confusion: TS playground
I found it a bit counterintuitive, but I understand it now; thank you for the example.
So the suggested approach is to provide the second generic to fromPromise
in order to keep the parameter (promiseCreator
) correctly typed, right? For context, I use signal
and sometimes emit
, so I need them typed.
Providing explicit generic to fromPromise
is probably the easiest.
Thank you, I think we can close then as there is a good enough solution.
XState version
XState version 5
Description
Using
fromPromise
for definingactors
insetup
, the parameterinput
is not inferred.Expected result
I expect the
input
to be inferred as theuseActor
works correctly and requiresinput
to be provided.Actual result
Property 'myInput' does not exist on type '{}'. ts(2339)
Reproduction
https://codesandbox.io/p/devbox/xstate-ts-actor-input-frompromise-infer-zwfvs5?file=%2Fsrc%2FfeedbackMachine.ts%3A26%2C63-26%2C76
Additional context
xstate: 5.18.2 @xstate/svelte: 3.0.5