i reran npx wrangler types to generate a
i reran npx wrangler types to generate a new worker-configuration.d.ts, and instead of doing this:
interface Env {
...
}
it did:
declare namespace Cloudflare {
interface Env {
...
}
}
interface Env extends Cloudflare.Env {}
and now my env doesn't work anywhere... (context.cloudflare.env doesn't have any of my types on it) Has anyone run into this or know how to fix it? (this is in a remix app, but I've updated to wrangler 4 and been using it fine for a bit...)
3 Replies
I tracked this down to
@cloudflare/workers-types
being installed as a peer dep, and the Cloudflare.Env
referencing the empty one in that. I found a workaround by adding import "./worker-configuration.d.ts"
at the top of the root file using the Env
and it fixed the resolution.Thanks for this info! However, this work around kind of defeats the purpose of having the types specified in the ts config though.
To be totally frank, I just downgraded the worker-type package to 4.0.0 as a work around. I'll wait for the SDK team to flush the new cloudflare namespace definition
It actually would be nice if they could publish a version of workers-types that’s empty, so we could pin to that version with npm overrides, to get around the issue of it getting installed as a peer dep