Skip to content

Commit 646786a

Browse files
committed
Add TS support for importable env
1 parent f7688f6 commit 646786a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

types/defines/rpc.d.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Extend this in your apps to properly type Env
2+
interface Env {}
3+
14
// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
25
// to referenced by `Fetcher`. This is included in the "importable" version of the types which
36
// strips all `module` blocks.
@@ -239,8 +242,15 @@ declare module "cloudflare:workers" {
239242
};
240243

241244
export abstract class WorkflowStep {
242-
do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
243-
do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
245+
do<T extends Rpc.Serializable<T>>(
246+
name: string,
247+
callback: () => Promise<T>
248+
): Promise<T>;
249+
do<T extends Rpc.Serializable<T>>(
250+
name: string,
251+
config: WorkflowStepConfig,
252+
callback: () => Promise<T>
253+
): Promise<T>;
244254
sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
245255
sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
246256
}
@@ -257,6 +267,11 @@ declare module "cloudflare:workers" {
257267

258268
constructor(ctx: ExecutionContext, env: Env);
259269

260-
run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
270+
run(
271+
event: Readonly<WorkflowEvent<T>>,
272+
step: WorkflowStep
273+
): Promise<unknown>;
261274
}
275+
276+
export const env: Env;
262277
}

0 commit comments

Comments
 (0)