From 03b071ff855c224b5e6d5eaf0baf50657aeea385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Duarte?= Date: Mon, 14 Oct 2024 18:59:28 +0100 Subject: [PATCH] fix: change WorkflowStep into an abstract class (#2916) For some reason, Typescript resolves types in a different away compared to abstract classes. As a consequence, it would not apply the overloading properly and always treats WorkflowStep.do as a 3 argument function --- types/defines/rpc.d.ts | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/types/defines/rpc.d.ts b/types/defines/rpc.d.ts index d714628cd3c..11d7e3fe652 100644 --- a/types/defines/rpc.d.ts +++ b/types/defines/rpc.d.ts @@ -233,26 +233,12 @@ declare module "cloudflare:workers" { timestamp: Date; }; - export type WorkflowStep = { - do: - | (>( - name: string, - callback: () => Promise - ) => Promise) - | (>( - name: string, - config: WorkflowStepConfig, - callback: () => Promise - ) => Promise) - | (>( - name: string, - config: WorkflowStepConfig | (() => Promise), - callback?: () => Promise - ) => Promise); - + export abstract class WorkflowStep { + do>(name: string, callback: () => Promise): Promise; + do>(name: string, config: WorkflowStepConfig, callback: () => Promise): Promise; sleep: (name: string, duration: WorkflowSleepDuration) => Promise; sleepUntil: (name: string, timestamp: Date | number) => Promise; - }; + } export abstract class WorkflowEntrypoint< Env = unknown,