From 2c207a8ed2076ec521c0b69155cb5e3980fa1014 Mon Sep 17 00:00:00 2001 From: Sid Chatterjee Date: Thu, 8 Aug 2024 16:13:16 +0100 Subject: [PATCH] remove incorrect import --- types/defines/rpc.d.ts | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/types/defines/rpc.d.ts b/types/defines/rpc.d.ts index bc3e2bdaa91..c99844287cd 100644 --- a/types/defines/rpc.d.ts +++ b/types/defines/rpc.d.ts @@ -1,8 +1,5 @@ // Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need // to referenced by `Fetcher`. This is included in the "importable" version of the types which - -import { Serializable } from "child_process"; - // strips all `module` blocks. declare namespace Rpc { // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. @@ -158,7 +155,8 @@ declare module "cloudflare:workers" { // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC export abstract class WorkerEntrypoint - implements Rpc.WorkerEntrypointBranded { + implements Rpc.WorkerEntrypointBranded + { [Rpc.__WORKER_ENTRYPOINT_BRAND]: never; protected ctx: ExecutionContext; @@ -174,7 +172,8 @@ declare module "cloudflare:workers" { } export abstract class DurableObject - implements Rpc.DurableObjectBranded { + implements Rpc.DurableObjectBranded + { [Rpc.__DURABLE_OBJECT_BRAND]: never; protected ctx: DurableObjectState; @@ -196,18 +195,29 @@ declare module "cloudflare:workers" { webSocketError?(ws: WebSocket, error: unknown): void | Promise; } - export type DurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; - export type SleepDuration = `${number} ${DurationLabel}${'s' | ''}` | number; - + export type DurationLabel = + | "second" + | "minute" + | "hour" + | "day" + | "week" + | "month" + | "year"; + export type SleepDuration = `${number} ${DurationLabel}${"s" | ""}` | number; type WorkflowStep = { - do: (name: string, callback: () => T) => T | Promise; - sleep:(name: string, duration: SleepDuration) => void | Promise; - } - + do: ( + name: string, + callback: () => T + ) => T | Promise; + sleep: (name: string, duration: SleepDuration) => void | Promise; + }; - export abstract class Workflow - implements Rpc.WorkflowBranded { + export abstract class Workflow< + Env = unknown, + T extends Serializable | unknown = unknown, + > implements Rpc.WorkflowBranded + { [Rpc.__WORKFLOW_BRAND]: never; protected ctx: ExecutionContext; @@ -215,8 +225,8 @@ declare module "cloudflare:workers" { run( events: Array<{ - payload: T, - timestamp: Date + payload: T; + timestamp: Date; }>, step: WorkflowStep ): unknown | Promise;