Skip to content

ispivey/workers-types

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare Workers Types

Install

npm install --save-dev @cloudflare/workers-types
-- Or
yarn add -D @cloudflare/workers-types

Usage

Just supply an empty import in one of your source files to receive the workers types

import {} from '@cloudflare/workers-types'

Make sure that the DOM, DOM.Iterable and WebWorker libraries are included in your tsconfig.json. e.g.:

"lib": ["DOM", "DOM.Iterable", "WebWorker"] // As well as "ESNext", etc. as your project requires

@cloudflare/workers-types definitions are merged with WebWorker while DOM and DOM.Iterable are used in the Request, Response and Headers interfaces.

Using a KV namespace

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

types.d.ts

import { KVNamespace } from '@cloudflare/workers-types'

declare global {
  const myKVNamespace: KVNamespace
}

Now myKVNamespace is available to all of your source files.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%