From c586214f8ea4567b8f1729f38ba344f95fc11f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 1 Jan 2024 19:00:21 +0100 Subject: [PATCH] Make `spawn` to type `input` option correctly based on concrete logics (#4644) Co-authored-by: Sam Armstrong --- packages/core/src/spawn.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/core/src/spawn.ts b/packages/core/src/spawn.ts index 2a29115d83..fa3702c4b4 100644 --- a/packages/core/src/spawn.ts +++ b/packages/core/src/spawn.ts @@ -1,20 +1,18 @@ -import { createErrorActorEvent } from './eventUtils.ts'; import { ProcessingStatus, createActor } from './createActor.ts'; import { ActorRefFrom, - AnyActorScope, AnyActorLogic, AnyActorRef, + AnyActorScope, AnyEventObject, AnyMachineSnapshot, + ConditionalRequired, InputFrom, IsLiteralString, + IsNotNever, ProvidedActor, - Snapshot, - TODO, RequiredActorOptions, - IsNotNever, - ConditionalRequired + TODO } from './types.ts'; import { resolveReferencedActor } from './utils.ts'; @@ -52,13 +50,12 @@ export type Spawner = IsLiteralString< logic: TSrc, ...[options = {} as any]: SpawnOptions ) => ActorRefFrom> - : // TODO: do not accept machines without all implementations - ( + : ( src: TLogic, options?: { id?: string; systemId?: string; - input?: unknown; + input?: TLogic extends string ? unknown : InputFrom; syncSnapshot?: boolean; } ) => TLogic extends string ? AnyActorRef : ActorRefFrom;