Argument of type 'Actor<StateMachine<MachineContext, AnyEventObject, {}, never, never, never, never, "init" | "done", string, NonReducibleUnknown, NonReducibleUnknown, { ...; }, MetaObject, ResolveTypegenMeta<...>>>' is not assignable to parameter of type 'AnyActorRef'.
Types of property 'on' are incompatible.
Type '<TType extends "FOO" | "*">(type: TType, handler: (emitted: { type: "FOO"; } & (TType extends "*" ? {} : { type: TType; })) => void) => Subscription' is not assignable to type '<TType extends string>(type: TType, handler: (emitted: EventObject & (TType extends "*" ? {} : { type: TType; })) => void) => Subscription'.
Types of parameters 'type' and 'type' are incompatible.
Type 'TType' is not assignable to type '"FOO" | "*"'.
Type 'string' is not assignable to type '"FOO" | "*"'.
XState version
XState version 5
Description
After #4905, there's some problem using
toPromise
on an actor created from a machine wheretypes.emitted
is specified.Example machine:
Usage:
Expected result
Would not expect a TS error here.
Actual result
(See playground
Reproduction
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgUxMGAaOBnZMCuYWMEAClBGrlgMZTICGMyAgjSVHAL5wBmFIOAHIAHthhNkQgNwAoWTQgA7cXBAMaAC2BLkcALw48hABQJZcODACeYZNgBciC5ZRoYzACZOEPBtkQbOychADEAeXChLhcYrgBKADo6RmYAWQ1tXTMXHXRgBgAbELyYIQwXcUlHZ1c4Up8XOstkJRgoaycAbSbmutR0MyDkEIiohN66gF0KvssigHcGaxqhT2UpXq5Z13XdH2GQ3h0i6NjZBLkFZVUNDgM4FMk2DhN1LR1kJKrYE3j5EjkSjAXAmO7Qf6yIA
Additional context
No response