Skip to content

Commit

Permalink
[core] Revert actorRefFrom change (#5029)
Browse files Browse the repository at this point in the history
* Revert `ActorRefFrom` change

* Changeset
  • Loading branch information
davidkpiano authored Aug 12, 2024
1 parent a275d27 commit 88bd87a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-lions-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

Revert `ActorRefFrom` change
44 changes: 41 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2008,9 +2008,47 @@ export type ActorLogicFrom<T> = ReturnTypeOrValue<T> extends infer R

// TODO: in v6, this should only accept AnyActorLogic, like ActorRefFromLogic
export type ActorRefFrom<T> = ReturnTypeOrValue<T> extends infer R
? R extends AnyActorLogic
? ActorRefFromLogic<R>
: never
? R extends StateMachine<
infer TContext,
infer TEvent,
infer TChildren,
infer _TActor,
infer _TAction,
infer _TGuard,
infer _TDelay,
infer TStateValue,
infer TTag,
infer _TInput,
infer TOutput,
infer TEmitted,
infer TMeta,
infer TStateSchema
>
? ActorRef<
MachineSnapshot<
TContext,
TEvent,
TChildren,
TStateValue,
TTag,
TOutput,
TMeta,
TStateSchema
>,
TEvent,
TEmitted
>
: R extends Promise<infer U>
? ActorRefFrom<PromiseActorLogic<U>>
: R extends ActorLogic<
infer TSnapshot,
infer TEvent,
infer _TInput,
infer _TSystem,
infer TEmitted
>
? ActorRef<TSnapshot, TEvent, TEmitted>
: never
: never;

export type ActorRefFromLogic<T extends AnyActorLogic> = ActorRef<
Expand Down

0 comments on commit 88bd87a

Please sign in to comment.