release-cloudflare-worker icon indicating copy to clipboard operation
release-cloudflare-worker copied to clipboard

Wrangler Type Generation

Open flakey5 opened this issue 9 months ago • 0 comments

Wrangler has a feature that generates the appropriate types for the APIs a worker has access to based off of the worker's compatability_date setting (re wrangler types).

I think it's worthwhile to try using that command vs what we're currently doing (using the @cloudflare/workers-types package):

  • We don't change our compatibility_date often (there isn't really a need to unless we want some new feature), so any changes to the @cloudflare/workers-types package don't change anything for us.
  • There's currently a possibility of a disconnect between our compatability_date and the types that we're actually using in our tsconfig file as well.

However, I don't think we should be using the Env interface generation that wrangler types supports (i.e. from the vars defined in wrangler.jsonc, it will generate an interface w/ appropriate types). There are pros to using it, however, we would lose the inline documentation that we currently have with it, so I think it'd be better to go without.

Noteworthy that I've only ever used wrangler types on new Workers projects, it should work here but I don't fully know if there's any caveats that may come up

flakey5 avatar Apr 21 '25 19:04 flakey5