Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

cloudflare-shim.d.ts

53 lines2.4 KB

1/* eslint-disable @typescript-eslint/consistent-type-imports --
2 global declaration file: a top-level import would turn it into a module */
3// Companion to the wrangler-generated worker-configuration.d.ts (env-only
4// mode — `pnpm run types`). Full runtime-type generation clashes with lib.dom
5// in this single-tsconfig SSR app, so binding types are aliased from
6// @cloudflare/workers-types as type-only imports (no fetch/Response globals),
7// and the cloudflare:workers module is declared against the generated
8// Cloudflare.Env so bindings/vars/secrets stay auto-generated.
9type KVNamespace = import('@cloudflare/workers-types').KVNamespace
10type D1Database = import('@cloudflare/workers-types').D1Database
11// workers-types computes `ctx.exports` from a module-scoped `Cloudflare`
12// namespace, so the generated GlobalProps never reach it. Type the one
13// loopback binding this app uses (`enable_ctx_exports`) by hand.
14type ExecutionContext = Omit<
15 import('@cloudflare/workers-types').ExecutionContext,
16 'exports'
17> & {
18 exports: {
19 /** `src/worker.ts` CachedReads, in lib.dom terms. */
20 CachedReads: {
21 fetch: (request: Request) => Promise<Response>
22 purge: () => Promise<void>
23 }
24 }
26type SendEmail = import('@cloudflare/workers-types').SendEmail
27type ScheduledController =
28 import('@cloudflare/workers-types').ScheduledController
29​
30declare module 'cloudflare:workers' {
31 export const env: Cloudflare.Env
32​
33 /** Extends the current request's lifetime past the response (workerd-native). */
34 export function waitUntil(promise: Promise<unknown>): void
35​
36 /** Durable Object base class (US_EGRESS, `src/server/us-egress-object.ts`). */
37 export const DurableObject: typeof import('@cloudflare/workers-types').CloudflareWorkersModule.DurableObject
38​
39 /** Named entrypoint base class (`CachedReads`, `src/worker.ts`). */
40 export const WorkerEntrypoint: typeof import('@cloudflare/workers-types').CloudflareWorkersModule.WorkerEntrypoint
42​
43type DurableObjectNamespace<
44 T extends
45 | import('@cloudflare/workers-types').Rpc.DurableObjectBranded
46 | undefined = undefined,
47> = import('@cloudflare/workers-types').DurableObjectNamespace<T>
48​
49/** Cloudflare Browser Rendering binding; keep runtime globals scoped. */
50type BrowserRun = import('@cloudflare/workers-types').BrowserRun
51​
52/** Workers AI binding; the FAL extract calls AI Gateway through it. */
53type Ai = import('@cloudflare/workers-types').Ai