{"id":13727149,"url":"https://github.com/cloudflare/workers-types","last_synced_at":"2025-05-07T22:30:52.167Z","repository":{"id":37270265,"uuid":"200418299","full_name":"cloudflare/workers-types","owner":"cloudflare","description":"TypeScript type definitions for authoring Cloudflare Workers.","archived":true,"fork":false,"pushed_at":"2023-01-20T03:01:09.000Z","size":267,"stargazers_count":359,"open_issues_count":0,"forks_count":89,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-01-15T00:31:50.311Z","etag":null,"topics":["cloudflare-workers","typescript","typescript-definitions","workers-types"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudflare.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2019-08-03T20:30:30.000Z","updated_at":"2025-01-02T10:32:49.000Z","dependencies_parsed_at":"2023-02-11T23:16:35.815Z","dependency_job_id":null,"html_url":"https://github.com/cloudflare/workers-types","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fworkers-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fworkers-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fworkers-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflare%2Fworkers-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudflare","download_url":"https://codeload.github.com/cloudflare/workers-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252965219,"owners_count":21832840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-workers","typescript","typescript-definitions","workers-types"],"created_at":"2024-08-03T01:03:41.637Z","updated_at":"2025-05-07T22:30:51.568Z","avatar_url":"https://github.com/cloudflare.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Cloudflare Workers Types\n\n:stop_sign: This repository was for `@cloudflare/workers-types` versions ≤ 3 and is no longer maintained.\n\nSince version 4, types are automatically generated from and in the [`workerd`](https://github.com/cloudflare/workerd) repository.\n\nFind the [new `README` here](https://github.com/cloudflare/workerd/tree/main/npm/workers-types) and the [new auto-generation scripts here](https://github.com/cloudflare/workerd/tree/main/types).\n\nPlease raise issues with type definitions [in the `workerd` repository](https://github.com/cloudflare/workerd/issues/new/choose), tagging `@cloudflare/workers-types` in your report.\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003eLegacy Documentation\u003c/summary\u003e\n\n## Install\n\n```bash\nnpm install -D @cloudflare/workers-types\n-- Or\nyarn add -D @cloudflare/workers-types\n```\n\n## Usage\n\n\u003e :warning: If you're upgrading from version 2, make sure to remove `webworker` from the `lib` array in your\n\u003e `tsconfig.json`. These types are now included in `@cloudflare/workers-types`.\n\nThe following is a minimal `tsconfig.json` for use alongside this package:\n\n**`tsconfig.json`**\n\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2020\",\n    \"module\": \"CommonJS\",\n    \"lib\": [\"ES2020\"],\n    \"types\": [\"@cloudflare/workers-types\"]\n  }\n}\n```\n\n### Using bindings\n\nIt's recommended that you create an ambient type file for any bindings your Worker uses. Create a file named\n`bindings.d.ts` in your src directory:\n\n**`bindings.d.ts`**\n\n```typescript\nexport {};\n\ndeclare global {\n  const MY_ENV_VAR: string;\n  const MY_SECRET: string;\n  const myKVNamespace: KVNamespace;\n}\n```\n\n## Auto-Generation\n\nTypes are automatically generated from the Workers runtime's source code on every release. However, these generated\ntypes don't include any generics or overloads, so to improve ergonomics, some of them are overridden.\n\nThe [`overrides`](./overrides) directory contains partial TypeScript declarations. If an override has a different type\nclassification than its generated counterpart – for example, an `interface` is declared to override a generated `class`\ndefinition – then the override is used instead of the generated output. However, if they're the same type classification\n(e.g. both the override and the generated output are using `class`), then their member properties are merged:\n\n- Members in the override but not in the generated type are included in the output\n- If a member in the override has the same name as one in the generated type, the generated one is removed from the\n  output, and the override is included instead\n- If the member is declared type `never` in the override, it is removed from the output\n\nIf a named type override is declared as a type alias to `never`, that named type is removed from the output.\n\nJSDoc comments from overrides will also be copied over to the output.\n\nComment overrides can also be written in Markdown. The [`docs`](./docs) directory contains these overrides.\n2\u003csup\u003end\u003c/sup\u003e level headings are the names of top level declarations (e.g. \u003ccode\u003e## \\`KVNamespace\\`\u003c/code\u003e),\n3\u003csup\u003erd\u003c/sup\u003e level headings are for member names (e.g. \u003ccode\u003e### \\`KVNamespace#put\\`\u003c/code\u003e), and 4\u003csup\u003eth\u003c/sup\u003e level\nheadings correspond to JSDoc sections for members:\n\n- `#### Parameters`: a list with parameters of the form \u003ccode\u003e- \\`param\\`: param description\u003c/code\u003e, these will be\n  formatted as `@param` tags\n- `#### Returns`: contents will be copied as-is to the `@returns` tag\n- `#### Examples`: fenced code blocks with the language set to `js`, `ts`, `javascript` or `typescript` will be copied\n  to `@example` tags\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflare%2Fworkers-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudflare%2Fworkers-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflare%2Fworkers-types/lists"}