Skip to content

Commit 0ace55d

Browse files
committed
Fix CI: declare Cloudflare.Env so astro check passes without wrangler types
The cloudflare:workers module types `env` as `Cloudflare.Env`, which is populated by `wrangler types` into the gitignored `worker-configuration.d.ts`. CI doesn't have that file, so `Env` was empty and `env.WAITLIST` failed type checking. Previous `declare module 'cloudflare:workers'` augmentation was a no-op because the module uses `export =` (CommonJS). Declaring `Cloudflare.Env` directly mirrors what wrangler generates and lets TS merge both declarations locally while keeping CI green.
1 parent c1fd856 commit 0ace55d

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/env.d.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/// <reference types="astro/client" />
22

3-
type RuntimeEnv = {
4-
WAITLIST: KVNamespace;
5-
PUBLIC_URL: string;
6-
};
7-
8-
declare module 'cloudflare:workers' {
9-
const env: RuntimeEnv;
10-
export { env };
3+
// Mirrors the shape generated by `wrangler types` into
4+
// `worker-configuration.d.ts` (which is gitignored). Declaring it here keeps
5+
// CI type-checking green even when the wrangler-generated file is absent,
6+
// and TS will merge both declarations when it IS present locally.
7+
declare namespace Cloudflare {
8+
interface Env {
9+
WAITLIST: KVNamespace;
10+
PUBLIC_URL: string;
11+
}
1112
}
13+
14+
interface Env extends Cloudflare.Env {}

0 commit comments

Comments
 (0)