Repository navigation
Description
Problem
@cloudflare/workers-types is a hand-picked devDependency, and picking its version is a recurring judgement call rather than a fact anyone can read off the config.
#84 was one round of that. PR #88 resolved it and showed the cost: [email protected] declares a peer of ^5.20260903.1, @universal-middleware/[email protected] declares ^4.20260608.1, and the ranges are disjoint. No single version satisfies both, so the PR had to argue for which unmet peer to prefer, and #84's acceptance criterion 2 ("no unmet peer") turned out to be unreachable as written.
The version is also picked to match the runtime by hand: [email protected] bundles [email protected], and 5.20260903.x is the types line for that date. Nothing enforces that pairing.
Separately, WEMEDITATE_CACHE: KVNamespace is hand-declared twice — types/vike.d.ts:67 and server/cms-context.ts:28 — while wrangler.toml:9-12 already declares the binding.
Proposal
Adopt Cloudflare's current guidance: wrangler types, which generates a worker-configuration.d.ts from the Wrangler config.
- Runtime types come from the wrangler that emulates the runtime, matched to the
compatibility_dateandcompatibility_flagswe actually deploy with (2025-09-06,nodejs_compat). - The disjoint-peer trade above disappears with the dependency.
- The generated
Envinterface is built from the declared bindings, soWEMEDITATE_CACHEstops being hand-declared.
What was confirmed — and what it turned up
⚠ The stated prerequisite passes. A different one fails, and it blocks the ticket as written.
wrangler.toml:4 sets main = "virtual:photon:cloudflare:server-entry". That is fine: wrangler types never resolves main, exits 0, and emits worker-configuration.d.ts (15,381 lines) whose Env types WEMEDITATE_CACHE: KVNamespace. Acceptance criterion 1 is met.
Criteria 3, 4 and 5 cannot all hold under one tsconfig.json. The generated file also declares the workerd runtime globals, and this repo has a single tsconfig with no include, so browser code and Worker code compile in one program. Committing the file and removing @cloudflare/workers-types turns a clean pnpm typecheck into two errors, both in code that runs in the browser:
components/organisms/RelatedContent/RelatedContentLoader.tsx:58— workerd'sBody.json<T>(): Promise<T>shadows the DOM'sPromise<any>, sores.json()resolves toPromise<unknown>.@ladle/react, inside its own bundled typings (typings-for-build/app/src/icons.tsx:55) — a globalElementfrom the runtime types no longer satisfiesEffectCallback.
Both were reproduced on main at c566dac: baseline pnpm typecheck is clean, and the two errors appear only once the generated file is in the program.
This is also why the hand-picked dependency was safe. It was only ever import type-ed, never listed in tsconfig.json's types, so its globals never entered the program at all. wrangler types has no equivalent import-only mode.
Open questions
- Which shape does this take? Neither is this ticket as written:
- Give
server/**its own tsconfig and scope the generated runtime types to it. Real work, and it changes whatpnpm typecheckmeans. - Keep
@cloudflare/workers-typesand pin it deliberately, accepting that the disjoint peer stays a judgement call, and record the wrangler/workerd pairing somewhere a reader can check.
- Give
- Or close this. The problem it describes is real but small, and neither option above is clearly worth its cost.
Acceptance criteria
— confirmed, 2026-09-08.wrangler typesruns in this repo and emitsworker-configuration.d.tswithWEMEDITATE_CACHEtyped as a KV namespace.- The generated file is either committed or generated in a
postinstall/predevstep — decide which, and say why in the PR. @cloudflare/workers-typesis removed fromdevDependencies, andpnpm installreports no unmet peer for it.server/kv-cache.ts,server/cms-context.tsandtypes/vike.d.tsresolveKVNamespacefrom the generated types.pnpm typecheck,pnpm test:runandpnpm buildpass; the Worker preview boots.
⚠ 3, 4 and 5 are not jointly satisfiable today — see above. Resolve the open questions before restoring Stage: Implement.
Origin
Raised as a consider finding on PR #88's adversarial review, scoped out of that PR at the time: #88 (comment)
🤖 Written by the sydevs autonomous loop — see what this is
Metadata
Metadata
Assignees
Labels
Type
Fields
Hold Until
Priority
Projects
- StatusShow more project fieldsDone
Activity
sydevs-bot commentedon Sep 8, 2026
Not viable as written —
Stagemoved back toRevising. The prerequisite it names passes; a different one fails.✅
wrangler typesruns here. The virtualmainis never resolved, and the emittedEnvtypesWEMEDITATE_CACHE: KVNamespace. AC 1 is met.❌ AC 3 + 4 + 5 cannot all hold under one
tsconfig.json. The file also declares workerd runtime globals, and this repo compiles browser and Worker code in one program. Committing it and dropping@cloudflare/workers-typesturns a cleanpnpm typecheckinto two errors, both in browser code:RelatedContentLoader.tsx:58— workerdBody.json<T>(): Promise<T>shadows the DOM'sPromise<any>, sores.json()isPromise<unknown>.@ladle/react, in its own typings — a globalElementno longer satisfiesEffectCallback.The old dependency was safe for that reason: only ever
import type-ed, so its globals never entered the program.Two options, neither this ticket: give
server/**its own tsconfig, or keep@cloudflare/workers-typesand pin it. Which? Closing is also fine.🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Ardnived commentedon Sep 13, 2026
Let's leave this as it is for now