Skip to content

TypeScript type definitions for authoring Cloudflare Workers.

License

Notifications You must be signed in to change notification settings

mathew-cf/workers-types

This branch is 170 commits behind cloudflare/workers-types:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f736026 · Jan 26, 2021
Oct 28, 2020
Jun 11, 2020
Oct 28, 2020
May 15, 2020
Jun 11, 2020
Oct 29, 2020
May 22, 2020
Sep 15, 2020
Jul 2, 2020
Jan 26, 2021
Oct 29, 2020
Jun 11, 2020
Jun 10, 2020
Jun 11, 2020

Repository files navigation

Cloudflare Workers Types

Install

npm install @cloudflare/workers-types
-- Or
yarn add @cloudflare/workers-types

Usage

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

tsconfig.json

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

Using bindings

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
}

About

TypeScript type definitions for authoring Cloudflare Workers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%