Workers RPC — TypeScript · Cloudflare Workers docs | Latest TMZ Celebrity News & Gossip | Watch TMZ Live Skip to content
Cloudflare Docs

TypeScript

Running wrangler types generates runtime types including the Service and DurableObjectNamespace types, each of which accepts a single type parameter for the WorkerEntrypoint or DurableObject types.

Using higher-order types, we automatically generate client-side stub types (e.g., forcing all methods to be async).

wrangler types also generates types for the env object. You can pass in the path to the config files of the Worker or Durable Object being called so that the generated types include the type parameters for the Service and DurableObjectNamespace types.

For example, if your client Worker had bindings to a Worker in ../sum-worker/ and a Durable Object in ../counter/, you should generate types for the client Worker's env by running:

Terminal window
npx wrangler types -c ./client/wrangler.jsonc -c ../sum-worker/wrangler.jsonc -c ../counter/wrangler.jsonc

This will produce a worker-configuration.d.ts file that includes:

worker-configuration.d.ts
interface Env {
SUM_SERVICE: Service<import("../sum-worker/src/index").SumService>;
COUNTER_OBJECT: DurableObjectNamespace<
import("../counter/src/index").Counter
>;
}

Now types for RPC method like the env.SUM_SERVICE.sum method will be exposed to the client Worker.

src/index.ts
export default {
async fetch(req, env, ctx): Promise<Response> {
const result = await env.SUM_SERVICE.sum(1, 2);
return new Response(result.toString());
},
} satisfies ExportedHandler<Env>;

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.