Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4133 pages
Node.js, PHP and APIs

tsc rejects Buffer<ArrayBuffer> or reports errors inside @types/node/buffer.d.ts

Your error

error TS2315: Type 'Buffer' is not generic.3 more lines it can show

Fix it fast

Most common cause, 1 of 3

@types/node is older than the generic Buffer

Install the newest @types/node for the Node.js major you run in production.

Fix
# Node.js 24 in production
npm install --save-dev @types/node@24
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Since TypeScript 5.7, typed arrays like Uint8Array take a type parameter, and newer @types/node releases made Buffer generic to match. Code or a library typed against the new Buffer<...> fails with TS2315 when an older @types/node is installed, and an old @types/node also breaks against a new compiler. Update @types/node to the latest release for your Node.js major version.

  • Applies to TypeScript 5.9, @types/node 20.11 to 24.19, Node.js 24
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the compiler version and every copy of @types/node in the dependency tree. Most cases are an old copy, sometimes pulled in by another package.

Run this first
npx tsc --version
npm ls @types/node

Then find the line you see in this list and open its fix:

  1. 1@types/node is older than the generic BufferTS2315 at a line that writes Buffer<...>, in your code or in a library's .d.ts
  2. 2An old @types/node meets TypeScript 5.7 or newerErrors point inside node_modules/@types/node, for example TS2430 in buffer.d.ts or TS2344 in fs/promises.d.ts
  3. 3A second, older @types/node is installed by another packagenpm ls @types/node lists more than one version

What does the error look like?

  • error TS2315: Type 'Buffer' is not generic.
  • node_modules/@types/node/buffer.d.ts: error TS2430: Interface 'Buffer' incorrectly extends interface 'Uint8Array<ArrayBufferLike>'.
  • error TS2344: Type 'Buffer' does not satisfy the constraint 'ArrayBufferView'.
  • error TS2322: Type 'Buffer<ArrayBufferLike>' is not assignable to type 'Uint8Array<ArrayBuffer>'.

Cause 1 of 3

@types/node is older than the generic Buffer

You seeTS2315 at a line that writes Buffer<...>, in your code or in a library's .d.ts

Check

Buffer takes a type parameter from @types/node 22.8.0 and 20.17.0 onward; 22.7.0 and 20.16.5 still reject Buffer<ArrayBuffer> under TypeScript 5.9. A library built against a recent @types/node ships declarations that use the generic form, so it can trigger this in a project that never wrote Buffer<...> itself.

Check
node -p "require('@types/node/package.json').version"

Fix

Install the newest @types/node for the Node.js major you run in production. It updates the declarations and does not change runtime behaviour.

Fix
# Node.js 24 in production
npm install --save-dev @types/node@24

Verify

The type check runs clean.

Verify
npx tsc --noEmit

Confirmed by typescriptlang.org

Did this fix it?

Cause 2 of 3

An old @types/node meets TypeScript 5.7 or newer

You seeErrors point inside node_modules/@types/node, for example TS2430 in buffer.d.ts or TS2344 in fs/promises.d.ts

Check

The TypeScript 5.7 notes say typed arrays became generic and that problems with Buffer usually mean @types/node needs an update. Old declarations describe Buffer in a way the new lib files no longer accept.

Check
npx tsc --noEmit 2>&1 | grep -c 'node_modules/@types/node'

Fix

Update @types/node as in the cause above. Turning on skipLibCheck hides the declaration errors but leaves Buffer mismatched in your own code, so treat it as a stopgap only.

Fix
npm install --save-dev @types/node@latest
npx tsc --noEmit

Verify

No errors reference files inside node_modules/@types/node.

Verify
npx tsc --noEmit 2>&1 | grep '@types/node' || echo clean

Confirmed by typescriptlang.org

Did this fix it?

Cause 3 of 3

A second, older @types/node is installed by another package

You seenpm ls @types/node lists more than one version

Check

Your package.json may already ask for a new version, while a dependency brings its own older copy that the compiler picks up in some folders.

Check
npm ls @types/node --all

Fix

Force one version across the tree with npm overrides, then reinstall.

Fix
// package.json
"overrides": {
  "@types/node": "$@types/node"
}

rm -rf node_modules package-lock.json && npm install

Verify

npm ls shows a single version, deduped everywhere, and tsc passes.

Verify
npm ls @types/node

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Update @types/node and TypeScript in the same pull request.
  • Pick the @types/node line that equals the Node.js release running on your servers, for example 24.x types for Node.js 24.
  • Run npm ls @types/node in CI to catch a second copy early.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.