From 88cbd32f0a20ed19cc73a0c11e364564ada15ebb Mon Sep 17 00:00:00 2001 From: Pablosinyores Date: Thu, 18 Jun 2026 15:21:43 +0530 Subject: [PATCH] fix(types): ArrayBuffer.prototype.resize returns void ArrayBuffer.prototype.resize() mutates the buffer in place and returns undefined per the ECMAScript spec, but bun-types declared it as returning ArrayBuffer. This also conflicts with TypeScript's own lib and core-js-types, which correctly type the return as void. --- packages/bun-types/globals.d.ts | 2 +- test/integration/bun-types/fixture/array-buffer.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index 4dd3dea89e07..8719feefd12e 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -1060,7 +1060,7 @@ interface ArrayBuffer { /** * Resize an ArrayBuffer in-place. */ - resize(byteLength: number): ArrayBuffer; + resize(byteLength: number): void; /** * Returns a section of an ArrayBuffer. diff --git a/test/integration/bun-types/fixture/array-buffer.ts b/test/integration/bun-types/fixture/array-buffer.ts index 7dcf9c4db30e..eab0c2b17b36 100644 --- a/test/integration/bun-types/fixture/array-buffer.ts +++ b/test/integration/bun-types/fixture/array-buffer.ts @@ -7,6 +7,11 @@ const buffer = new ArrayBuffer(1024, { console.log(buffer.byteLength); // 1024 buffer.resize(2048); console.log(buffer.byteLength); // 2048 + +// resize() mutates the buffer in place and returns undefined (void) per the +// ECMAScript spec, not the ArrayBuffer. +const resizeResult: void = buffer.resize(1024); +void resizeResult; TextDecoder; const buf = new SharedArrayBuffer(1024);