Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Automatically generated ESM Cloudflare Workers types

License

Notifications You must be signed in to change notification settings

thatmattlove/cloudflare-workers-types-esm

Repository files navigation

Cloudflare Workers Types (ESM)

your automatic band-aid for using @cloudflare/workers-types to ship Cloudflare Workers utilities and frameworks

@cloudflare/workers-types current version cloudflare-workers-types-esm current version

Quality Tests Build


⚠️ After the release of @cloudflare/workers-types, this project is (thankfully) no longer necessary.

If you're like me, you might think to yourself, "hey I could totally make this library that others and I can re-use when building Cloudflare Workers", and you get all the way to the end, go to test it, and see everybody's favorite TypeScript error:

This happens because the @cloudflare/workers-types package doesn't export its type definitions; which is why you need to reference them in your project's tsconfig.json file as global types.

Issue #195 has been opened to fix this, but because there is no timeline for completion and no ability to submit a PR (the type definitions are automatically generated), I created this package as a stopgap.

Installation

# NPM
npm install cloudflare-workers-types-esm
# Yarn
yarn add cloudflare-workers-types-esm
# PNPM
pnpm install cloudflare-workers-types-esm

Usage

Import (or export) the types as needed

import { KVNamespace } from "cloudflare-workers-types-esm";

export type MySpecialSnowflake = KVNamespace<string>;

Updates

cloudflare-workers-types-esm is automagically kept in sync with @cloudflare/workers-types with a GitHub Action workflow that runs hourly. When Cloudflare releases a new version of their type definitions, cloudflare-workers-types-esm will be updated to match it within an hour or so. That way, you don't have to wait on some unreliable maintainer to do stuff for you 👀

License

This package is subject to the license of the original @cloudflare/workers-types package