From 00f019bc60dc5f095782a8274b1b5397c86341a2 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Sat, 20 Jun 2026 19:45:29 +0800 Subject: [PATCH] fix(cloud-artifacts): make Env stubs actually take effect in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous stub file (2e29e362) wrapped `interface Env` in `declare global { ... }`, but the file has no top-level import/export so it's a script, not a module. TS2669 forbids `declare global` in scripts, and in .d.ts files that error is silently swallowed — so the Env stubs were never merged into the global scope. Locally typecheck passed only because worker-configuration.d.ts (gitignored) provided Env separately; in CI / fresh clones, `BUCKET`, `MAX_BYTES`, `DEFAULT_TTL_DAYS`, `PUBLIC_URL` were all missing on Env. Drop the wrapper. Top-level `interface Env` in a script .d.ts is already global ambient and merges with worker-configuration.d.ts via interface declaration merging, so both environments typecheck cleanly. Co-Authored-By: glm-5.2 --- packages/cloud-artifacts/src/types.d.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/cloud-artifacts/src/types.d.ts b/packages/cloud-artifacts/src/types.d.ts index 692a6e012..2d6ff7d20 100644 --- a/packages/cloud-artifacts/src/types.d.ts +++ b/packages/cloud-artifacts/src/types.d.ts @@ -90,13 +90,15 @@ interface ExportedHandler { // Wrangler-generated worker-configuration.d.ts supplies TOKEN via `wrangler secret put`. // This declaration provides the R2 binding + wrangler vars so the Worker compiles // without the generated file. - -declare global { - interface Env { - BUCKET: R2Bucket - TOKEN: string - MAX_BYTES: string - DEFAULT_TTL_DAYS: string - PUBLIC_URL: string - } +// +// NOTE: 这个文件是脚本(没有 top-level import/export),顶层 interface 自动是 global +// ambient,会和 worker-configuration.d.ts 的 `interface Env` 走 interface declaration +// merging。不要用 `declare global { ... }` 包裹——脚本文件里那种写法是 TS2669 错误, +// 在 .d.ts 里甚至会被静默吞掉,导致 Env 桩完全不生效(CI 上就是这种情况)。 +interface Env { + BUCKET: R2Bucket + TOKEN: string + MAX_BYTES: string + DEFAULT_TTL_DAYS: string + PUBLIC_URL: string }