Given the example in this gist, I'd expect that the self value would be assignable to type ActorRef<any, any, EmittedEvents>.
Actual result
index.ts:24:58 - error TS2322: Type 'ActorRef<MachineSnapshot<{ b?: ActorRef<MachineSnapshot<MachineContext, AnyEventObject, {}, {}, string, NonReducibleUnknown>, AnyEventObject, EventObject> | undefined; }, ... 4 more ..., unknown>, AnyEventObject, EventObject>' is not assignable to type 'ActorRef<any, any, EmittedEvents>'.
Type 'EventObject' is not assignable to type 'EmittedEvents'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"BAR"'.
24 b: ({spawn, self}) => spawn('machineB', { input: { a: self } })
~
Found 1 error in index.ts:24
XState version
XState version 5
Description
The
self
prop ofUnifiedArg
https://github.com/statelyai/xstate/blob/main/packages/core/src/types.ts#L114 is anActorRef
, but only provides the first two type arguments (snapshot andEventObject
for events). The third type arg, which is the "emitter", is left to the default value (EventObject
).Expected result
Given the example in this gist, I'd expect that the
self
value would be assignable to typeActorRef<any, any, EmittedEvents>
.Actual result
Reproduction
https://gist.github.com/boneskull/a4e139896f661dd0a8288b2af2f0f43d
Additional context
This may be an indication of a larger issue.
self
doesn't seem all that typesafe. For example, this does not fail compilation: