A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cloudflare/workers-types below:

cloudflare/workers-types: TypeScript type definitions for authoring Cloudflare Workers.

🛑 This repository was for @cloudflare/workers-types versions ≤ 3 and is no longer maintained.

Since version 4, types are automatically generated from and in the workerd repository.

Find the new README here and the new auto-generation scripts here.

Please raise issues with type definitions in the workerd repository, tagging @cloudflare/workers-types in your report.

Legacy Documentation
npm install -D @cloudflare/workers-types
-- Or
yarn add -D @cloudflare/workers-types

⚠️ If you're upgrading from version 2, make sure to remove webworker from the lib array in your tsconfig.json. These types are now included in @cloudflare/workers-types.

The following is a minimal tsconfig.json for use alongside this package:

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "lib": ["ES2020"],
    "types": ["@cloudflare/workers-types"]
  }
}

It's recommended that you create an ambient type file for any bindings your Worker uses. Create a file named bindings.d.ts in your src directory:

bindings.d.ts

export {};

declare global {
  const MY_ENV_VAR: string;
  const MY_SECRET: string;
  const myKVNamespace: KVNamespace;
}

Types are automatically generated from the Workers runtime's source code on every release. However, these generated types don't include any generics or overloads, so to improve ergonomics, some of them are overridden.

The overrides directory contains partial TypeScript declarations. If an override has a different type classification than its generated counterpart – for example, an interface is declared to override a generated class definition – then the override is used instead of the generated output. However, if they're the same type classification (e.g. both the override and the generated output are using class), then their member properties are merged:

If a named type override is declared as a type alias to never, that named type is removed from the output.

JSDoc comments from overrides will also be copied over to the output.

Comment overrides can also be written in Markdown. The docs directory contains these overrides. 2nd level headings are the names of top level declarations (e.g. ## `KVNamespace`), 3rd level headings are for member names (e.g. ### `KVNamespace#put`), and 4th level headings correspond to JSDoc sections for members:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4