Closed
Description
Bug Report
π Search Terms
Contextual inference
π Version & Regression Information
tested with 4.4.0-beta
β― Playground Link
π» Code
createMachine({
context: { foo: 1 },
entry: {
type: "xstate.assign",
exec: c => ({ foo: c.foo + 1 })
}
})
createMachine({
context: { foo: 1 },
entry: assign(c => ({ foo: c.foo + 1 })) // c is unknown but should be { foo: number } instead
})
declare const createMachine: <C>(defintion: Machine<C>) => {}
type Machine<C> = {
context: C,
entry: {
type: string,
exec: (context: C) => unknown
}
}
declare const assign: <C>(f: (context: C) => C) =>
{ type: "xstate.assign", exec: (context: C) => C }
π Actual behavior
assign
infers type parameter C
as unknown
π Expected behavior
assign
should infer type parameter C
as { foo: number }
Filing as Ryan said here. Fwiw I think a more minimal repro would be this.