workers-types v5 keeps only the latest runtime types!
Hey there, it's Shiichan! Today I've got a small but pleasant tidy-up from the world of Workers development.
Cloudflare ChangelogWhat was announced?
Cloudflare's Changelog announced version 5 of @cloudflare/workers-types. This package holds the runtime type definitions you use when writing Workers in TypeScript, and v5 trims it down to ship only the latest runtime types.
The story so far
Older releases of workers-types carried a pile of dated entrypoints like @cloudflare/workers-types/2022-11-30 and @cloudflare/workers-types/2023-03-01. It was easy to get lost deciding which one to import.
What changes
v5 removes those dated entrypoints and exposes just two:
@cloudflare/workers-typesreflects the latest compatibility date, using the latest stable compatibility flags.@cloudflare/workers-types/experimentalreflects APIs behind experimental compatibility flags.
Fewer choices means less time wondering which types to pull in.
Dive Deep
Cloudflare still recommends generating types with wrangler types rather than installing the package directly. But if you want the package, grab it with your favorite package manager:
npm i -D @cloudflare/workers-types@latest
To replace the removed dated entrypoints, use the runtime type generation in Wrangler v4. Running wrangler types builds types locked to your Worker's own compatibility date, which is more accurate. For the full picture, check out TypeScript language support.
Wrap-up
- @cloudflare/workers-types is now v5, shipping only the latest runtime types.
- Only two entrypoints remain:
@cloudflare/workers-typesand.../experimental. The dated ones are gone. - Want date-locked types? Generate them with wrangler types against your Worker's compatibility date.
If you write Workers in TypeScript, especially if you leaned on the old dated types, this cleanup is for you!