workers-types Env POC

This POC shows a simple example on how an Env type could be defined in the @cloudflare/workers-types package and extended/used externally (one of the main use cases being getPlatformProxy).

In src/index.ts you can see the Env type being expanded:

declare module '@cloudflare/workers-types/base' {
	interface Env {
		MY_VAR: number;
	}
}

Such expansion could be also implemented opt-in by wrangler types.


As I mentioned one of the biggest benefits of this would be the possible customization of the Env interface externally in combination with getPlatformProxy.

For example frameworks/libraries using getPlatformProxy could, without any change on their part, allow developers to customize their Env type (similarly to this example).

Related discussion: pi0/nitro-cloudflare-dev#13