cloudflare-workers-types-esm
v3.18.0
Published
Automatically generated Cloudflare Workers Types as ES Module
Downloads
9
Readme
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