Types for data: (context, event) =>
are 'any'
#1261
-
Hi. I have the following foo: {
invoke: {
src: ChildMachine,
data: (context, event) => ({
mode: event.type === 'ONE' ? 1 : event.type === 'TWO' ? 2 : undefined,
}),
onDone: 'bar',
},
}, The
Why doesn't it know the parameter types? I fixed the error for now by being more explicit, but it doesn't feel nice: foo: {
invoke: {
src: ChildMachine,
data: (context: ParentContext, event: ParentEvents): Partial<ChildContext> => ({
mode: event.type === 'ONE' ? 1 : event.type === 'TWO' ? 2 : undefined,
}),
onDone: 'bar',
},
}, Side note: is it possible to define |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thank you for the report - I've started working on fixing this. The problem is that currently
You could use |
Beta Was this translation helpful? Give feedback.
Thank you for the report - I've started working on fixing this. The problem is that currently
any
is included in some union types and this always makes the whole union equal toany
.You could use
services
to do that though - you would just have to returnChildMachine.withContext(/* ... */)
from a service creator based on received arguments (context
andevent
).