Skip to content

Wrangler Type Generation #394

@flakey5

Description

@flakey5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions