From 80b31f403ef65421bc00a11fd6a7af6c9d12fd2d Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 18 Jul 2024 10:31:00 -0700 Subject: [PATCH] chore(types): use HostForGuest consistently --- packages/orchestration/src/facade.js | 13 ++++--------- packages/orchestration/test/types.test-d.ts | 3 +++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/orchestration/src/facade.js b/packages/orchestration/src/facade.js index a147c7e0e523..f366b411369e 100644 --- a/packages/orchestration/src/facade.js +++ b/packages/orchestration/src/facade.js @@ -66,18 +66,13 @@ export const makeOrchestrationFacade = ({ const { prepareEndowment, asyncFlow, adminAsyncFlow } = asyncFlowTools; /** - * @template GR - return type * @template HC - host context - * @template {any[]} GA - guest args + * @template {OrchestrationFlow>} GF guest fn * @param {string} durableName - the orchestration flow identity in the zone * (to resume across upgrades) * @param {HC} hostCtx - values to pass through the async flow membrane - * @param {( - * guestOrc: Orchestrator, - * guestCtx: GuestInterface, - * ...args: GA - * ) => Promise} guestFn - * @returns {(...args: HostArgs) => Vow} + * @param {GF} guestFn + * @returns {HostForGuest} */ const orchestrate = (durableName, hostCtx, guestFn) => { const subZone = zone.subZone(durableName); @@ -92,7 +87,7 @@ export const makeOrchestrationFacade = ({ const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn); // cast because return could be arbitrary subtype - const orcFn = /** @type {(...args: HostArgs) => Vow} */ ( + const orcFn = /** @type {HostForGuest} */ ( (...args) => hostFn(wrappedOrc, wrappedCtx, ...args) ); diff --git a/packages/orchestration/test/types.test-d.ts b/packages/orchestration/test/types.test-d.ts index 4c55ba315e68..92f9c8de7587 100644 --- a/packages/orchestration/test/types.test-d.ts +++ b/packages/orchestration/test/types.test-d.ts @@ -144,7 +144,10 @@ expectNotType(chainAddr); ) => Promise.resolve(num); { const h = facade.orchestrate('name', undefined, slowEcho); + // TODO keep the return type as Vow + expectType<(num: number) => Vow>(h); expectType>(h(42)); + // @ts-expect-error literal not carried, widened to number expectType>(h(42)); }