Use with Deno
deno bundle is a great future-forward way of bundling Typescript into an ESM, and compared to webpack et al, is a great developer experience for writing Cloudflare Workers.
However, so far I've always resorted to creating my own types for the Cloudflare-specific APIs. It would be great to reuse the work here with Deno, but that hits a few barriers:
- types are not exported https://github.com/cloudflare/workers-types/issues/195
- many of the defined types conflict with Deno's definitions, and if you start stripping away the defaults (https://deno.land/[email protected]/typescript/types#using-triple-slash-directives), you end up with weirder conflicts like whether
EventListenerOrEventListenerObjectis generic or not.
It would be great to have a tested & upstreamed way of importing these types into a Deno program.
Community efforts:
- https://github.com/ericselin/worker-types (just the types, duplicating the effort here)
- https://github.com/skymethod/denoflare (this one seems like an alternate implementation of wrangler/miniflare?)
There's also my library samuelcolvin/edge-mock which tries to provide implementations of the types defined in workers-types for use in testing. It's targeted at node, but much of it could probably be used on deno.
Hey! 👋 Thanks for reporting this, we're actively thinking about ways of fixing this in the next major version of workers-types using the new type generation system. 👍
Hey! 👋 As of @cloudflare/workers-types@4, you can selectively import type { ... } from "@cloudflare/workers-types". Hopefully this is sufficient for your use case. There are no plans at the moment for officially supported Deno integration.