Repository navigation
bug: shared adapter type chunk breaks tsc for Node-only consumers without skipLibCheck #284
Description
Activity
Thanks for issue. I just spawned an agent to go with B, it might fix some other relavant issues we had.
BTW nice work on Koenkk/zigbee2mqtt#32685, LMK if could help anyhow ;)
Reacted by Alexander Chepurnoy- added 4 commits that reference this issue
on Jul 29, 2026 Verified against the
pkg.pr.newbuild of #287: 12 of the 13 errors are gone. Theaws-lambda/bun/@cloudflare/workers-types/cloudflare:workersimports and theDeno/FetchEventreferences all resolve now.One reference of the same kind is left, in the inlined Bun types:
dist/_chunks/types.d.mts(59,15): error TS2304: Cannot find name 'HeadersInit'.// dist/_chunks/types.d.mts:57-60 /** Upgrade an incoming request to a WebSocket connection. */ upgrade(request: Request, options?: { headers?: HeadersInit; data?: any; }): boolean;
@types/nodedoes not declareHeadersInit— onlyHeadersitself is ambient — so this still requireslib: ["dom"], which is whatResponseBodywas introduced to avoid. Deriving it the same way works; verified withlib: ["esnext"],@types/node26 and TypeScript 7.0.2,tscclean:/** * Headers accepted by the runtime `Headers` constructor (`HeadersInit`). * * Derived from the ambient `Headers` so that it does not require `lib: ["dom"]`. */ type HeadersInit = NonNullable<ConstructorParameters<typeof globalThis.Headers>[0]>;
It accepts
string[][],Record<string, string>andHeaders, matching the DOM/undici definition. Name is yours to pick, of course —ResponseBodysets the precedent.With that one line, srvx type-checks for a Node-only consumer with no
skipLibCheckand no extra type packages. Happy to send it as a PR.Landed in https://github.com/h3js/srvx/releases/tag/v0.12.5 just saw your last message feel free to drop a PR for inlining
HeadersInitbut also i guess it is fair that any consumer project require node and dom standard types.
Environment
srvx 0.12.4, TypeScript 7.0.2, @types/node 26, Node 24
Reproduction
tsconfig.json:{"module": "NodeNext", "target": "esnext", "lib": ["esnext"], "strict": true}npx tsc --noEmit→ 13 errors, all inside srvx's own.d.mts.Describe the bug
dist/_chunks/types.d.mtsis one shared chunk pulled in by every entrypoint, including the Node-onlysrvx/nodeandsrvx/static. It importsaws-lambda,bunand@cloudflare/workers-types, and references theDenonamespace andFetchEvent. All of those aredevDependenciesof srvx, so consumers never receive them — a Node-only project cannot type-check withoutskipLibCheck: true, even though it targets none of those runtimes.skipLibCheckis repo-wide, so working around one dependency also stops checking every other dependency's types.Separately,
dist/adapters/node.d.mts:43uses the globalBodyInit, which@types/nodedoes not provide and which needs"lib": ["dom"]. Importing it fromundici-typeswould avoid that.Additional context
Possible fixes, in order of preference:
.d.mtsis bundled, not from a real dependency.@types/aws-lambda,@types/bun,@cloudflare/workers-typesand@types/denoaspeerDependencieswithpeerDependenciesMeta: {"optional": true}.Happy to open a PR for (1) if you agree with the direction.
Logs