TypeScript types for the OpenWorkers runtime.
bun add -d @openworkers/workers-typesAdd to your tsconfig.json:
{
"compilerOptions": {
"lib": ["esnext"],
"types": ["@openworkers/workers-types"]
}
}This includes only OpenWorkers types and excludes conflicting types (like @types/node or @types/bun). Best for pure worker projects. Keep "lib": ["esnext"]: the default lib includes the DOM types, which declare the same globals.
If you need to mix with Node.js or Bun types, just install the package without configuring types. The types will merge with existing globals:
{
"compilerOptions": {
// no "types" array - all @types/* are included
}
}For per-file control:
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference types="@openworkers/workers-types" />TypeScript 6 ignores no-default-lib. With TypeScript 6, also set "lib": ["esnext"] in tsconfig.json.
types/globals.d.ts- selftypes/fetch.d.ts- Request, Response, Headers, fetchtypes/url.d.ts- URL, URLSearchParamstypes/streams.d.ts- ReadableStream, WritableStreamtypes/crypto.d.ts- Web Crypto APItypes/encoding.d.ts- TextEncoder, TextDecoder, atob, btoatypes/console.d.ts- Console APItypes/timers.d.ts- setTimeout, setIntervaltypes/events.d.ts- Event, EventTargettypes/abort.d.ts- AbortController, AbortSignaltypes/blob.d.ts- Blob, File, FormDatatypes/websocket.d.ts- WebSocket, WebSocketPairtypes/workers.d.ts- ExecutionContext, ScheduledEvent, ExportedHandlertypes/bindings.d.ts- BindingAssets, BindingStorage, BindingKV, BindingDatabase, BindingD1 (D1Database), BindingWorker