We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Contextual inference
tested with 4.4.0-beta
Playground
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 }
assign infers type parameter C as unknown
assign
C
unknown
assign should infer type parameter C as { foo: number }
{ foo: number }
Filing as Ryan said here. Fwiw I think a more minimal repro would be this.
Bug Report
π Search Terms
Contextual inference
π Version & Regression Information
tested with 4.4.0-beta
β― Playground Link
Playground
π» Code
π Actual behavior
assigninfers type parameterCasunknownπ Expected behavior
assignshould infer type parameterCas{ foo: number }Filing as Ryan said here. Fwiw I think a more minimal repro would be this.