What versions & operating system are you using?
System:
OS: macOS 27.0
CPU: (10) arm64 Apple M5
Memory: 2.37 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 26.4.0 - /opt/homebrew/bin/node
npm: 11.17.0 - /opt/homebrew/bin/npm
npmPackages:
wrangler: ^4.123.0 => 4.123.0
Also relevant (not covered by envinfo):
typescript: 5.9.3
@types/node: 22.20.1
Introduced in 4.122.0. Verified against 4.122.0 and 4.123.0 (both broken) and 4.121.0 (fine).
Please provide a link to a minimal reproduction
https://github.com/JacktheRanger/Wrangler-bug-reproduction
Describe the Bug
Summary
Since 4.122.0, wrangler types adds these two lines to the generated worker-configuration.d.ts:
declare const Buffer: any;
declare const process: any;
declare const Buffer: any collides with @types/node's var Buffer: BufferConstructor. The
resulting symbol conflict discards the members of the global interface Buffer from
@types/node, leaving only the Uint8Array shell it extends. skipLibCheck swallows the
duplicate-declaration error inside the .d.ts files, so nothing surfaces until a call site fails
with a confusing error far from the actual cause.
process is silently widened to any the same way. That one produces no error, it just removes
type checking from every process.* use in the project.
Steps to reproduce
wrangler.jsonc with "compatibility_date": "2026-08-04" (or later) and nodejs_compat
tsconfig.json with "types": ["./worker-configuration.d.ts", "node"]
- Any
Buffer.toString(encoding) call, e.g. pbkdf2Sync(...).toString('base64')
npx wrangler types && npx tsc --noEmit
Actual
src/index.ts(7,39): error TS2554: Expected 0 arguments, but got 1.
It is not just toString. Every Buffer-only member is gone, while members inherited from
Uint8Array still resolve — which is what pins the cause to the interface being nullified rather
than a single bad overload:
src/probe.ts(3,5): error TS2339: Property 'readUInt8' does not exist on type 'NonSharedBuffer'.
src/probe.ts(4,5): error TS2339: Property 'equals' does not exist on type 'NonSharedBuffer'.
src/probe.ts(5,5): error TS2339: Property 'toJSON' does not exist on type 'NonSharedBuffer'.
(buf.subarray(0, 4) on the same value type-checks fine.)
Expected
wrangler types should not emit declarations that override @types/node. Either omit
Buffer/process from the generated globals and let @types/node provide them, or declare them
with real types instead of any.
Worth noting the same release's changelog says wrangler types "no longer attributes its
@types/node suggestion to the nodejs_compat flag" — so Wrangler recommends installing
@types/node, and then emits a declaration that breaks it. Under nodejs_compat the Node typings
are the accurate ones for these globals, so any is strictly worse than deferring to them.
Note this only affects globals declared as const. The same batch emits
declare const global: ServiceWorkerGlobalScope (a concrete type, arguably better than
@types/node's typeof globalThis) and setImmediate/clearImmediate as function
declarations, which merge as overloads and cause no harm. Buffer and process are the only two
emitted as : any.
Regression range
| wrangler |
declare const X: any emitted |
tsc --noEmit |
| 4.121.0 |
none |
clean |
| 4.122.0 |
Buffer, process |
TS2554 |
| 4.123.0 |
Buffer, process |
TS2554 |
Likely from the 4.122.0 change that infers nodejs_compat from the compatibility date — our
compat date is exactly 2026-08-04, the day the flag became the default.
Workaround
Post-processing the generated file to strip top-level constants declared as any:
generated.replace(/^declare const [A-Za-z_$][A-Za-z0-9_$]*: any;\r?\n/gm, '')
In the generated output those are exactly Buffer and process; everything else declared at the
top level has a concrete type, so this leaves the rest of the runtime types untouched.
Please provide any relevant error logs
$ npx wrangler types
⛅️ wrangler 4.123.0
Generating project types...
Generating runtime types...
Runtime types generated.
✨ Types written to worker-configuration.d.ts
$ grep -n '^declare const [A-Za-z_$][A-Za-z0-9_$]*: any;$' worker-configuration.d.ts
440:declare const Buffer: any;
441:declare const process: any;
$ npx tsc --noEmit
src/index.ts(7,39): error TS2554: Expected 0 arguments, but got 1.
$ npx wrangler@4.121.0 types && npx tsc --noEmit
# (no any-typed globals emitted, tsc exits 0)
What versions & operating system are you using?
Also relevant (not covered by
envinfo):typescript: 5.9.3@types/node: 22.20.1Introduced in 4.122.0. Verified against 4.122.0 and 4.123.0 (both broken) and 4.121.0 (fine).
Please provide a link to a minimal reproduction
https://github.com/JacktheRanger/Wrangler-bug-reproduction
Describe the Bug
Summary
Since 4.122.0,
wrangler typesadds these two lines to the generatedworker-configuration.d.ts:declare const Buffer: anycollides with@types/node'svar Buffer: BufferConstructor. Theresulting symbol conflict discards the members of the global
interface Bufferfrom@types/node, leaving only theUint8Arrayshell it extends.skipLibCheckswallows theduplicate-declaration error inside the
.d.tsfiles, so nothing surfaces until a call site failswith a confusing error far from the actual cause.
processis silently widened toanythe same way. That one produces no error, it just removestype checking from every
process.*use in the project.Steps to reproduce
wrangler.jsoncwith"compatibility_date": "2026-08-04"(or later) andnodejs_compattsconfig.jsonwith"types": ["./worker-configuration.d.ts", "node"]Buffer.toString(encoding)call, e.g.pbkdf2Sync(...).toString('base64')npx wrangler types && npx tsc --noEmitActual
It is not just
toString. Every Buffer-only member is gone, while members inherited fromUint8Arraystill resolve — which is what pins the cause to the interface being nullified ratherthan a single bad overload:
(
buf.subarray(0, 4)on the same value type-checks fine.)Expected
wrangler typesshould not emit declarations that override@types/node. Either omitBuffer/processfrom the generated globals and let@types/nodeprovide them, or declare themwith real types instead of
any.Worth noting the same release's changelog says
wrangler types"no longer attributes its@types/nodesuggestion to thenodejs_compatflag" — so Wrangler recommends installing@types/node, and then emits a declaration that breaks it. Undernodejs_compatthe Node typingsare the accurate ones for these globals, so
anyis strictly worse than deferring to them.Note this only affects globals declared as
const. The same batch emitsdeclare const global: ServiceWorkerGlobalScope(a concrete type, arguably better than@types/node'stypeof globalThis) andsetImmediate/clearImmediateas functiondeclarations, which merge as overloads and cause no harm.
Bufferandprocessare the only twoemitted as
: any.Regression range
declare const X: anyemittedtsc --noEmitBuffer,processBuffer,processLikely from the 4.122.0 change that infers
nodejs_compatfrom the compatibility date — ourcompat date is exactly
2026-08-04, the day the flag became the default.Workaround
Post-processing the generated file to strip top-level constants declared as
any:In the generated output those are exactly
Bufferandprocess; everything else declared at thetop level has a concrete type, so this leaves the rest of the runtime types untouched.
Please provide any relevant error logs