cloudflare / cloudflare/workerd

Feature 🚀 : Add a new `Env` type that can be used and extended externally

Open
#1,899 1 comment 2 reactions 1 assignee Claimed by @workers-devprod View on GitHub
feature request types
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

Adding a new `Env` type in the workers-types package could be beneficial as it could be used/leveraged by users and library/framework authors.

I made this simple POC regarding this: https://github.com/dario-piotrowicz/workers-types-env-poc

(in the POC's `workers-types`'s node_modules directory you can see the type of change I have in mind, only applied to the `experimental` entrypoint there)

___

This could be beneficial for uses of `getPlatformProxy` such as [nitro-cloudflare-dev](https://github.com/pi0/nitro-cloudflare-dev) (see https://github.com/pi0/nitro-cloudflare-dev/pull/13)
(cc. @pi0, @Aslemammad)

___

We've been also asked about this from the Remix team once. Their reasoning there being that having an `Env` interface somewhere, always guaranteed to exist, allows for libraries to be written with more stable/robust typing instead of having to reply on a global `Env` interface that might or not exist, @pcattori please feel free to add context here regarding this if you want 🙂.

___

This needs a bit of discussion though as the introduction of such a type, although not complex would likely not be trivial and the effort of implementing and maintaining such type could outweigh the benefits 🤔

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.