You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
runs as expected and shows no errors in TypeScript 5.6, but the following error is shown with TypeScript 5.7:
No overload matches this call.
Overload 1 of 2, '(data: Data | null, status?: StatusCode | undefined, headers?: HeaderRecord | undefined): Response', gave the following error.
Argument of type 'Buffer<ArrayBuffer>' is not assignable to parameter of type 'Data | null'.
Type 'Buffer<ArrayBuffer>' is missing the following properties from type 'ArrayBuffer': maxByteLength, resizable, resize, detached, and 2 more.
Overload 2 of 2, '(data: Data | null, init?: ResponseInit | undefined): Response', gave the following error.
Argument of type 'Buffer<ArrayBuffer>' is not assignable to parameter of type 'Data | null'.
Type 'Buffer<ArrayBuffer>' is missing the following properties from type 'ArrayBuffer': maxByteLength, resizable, resize, detached, and 2 more.
shows no type error, but leads to unexpected results, as responses are 8192 bytes long and contain lots of unrelated data. The reason for this is the shared memory pool from the Buffer module:
What is the recommended way to use a Node.js Buffer as the body of a response? Do Hono’s types need to be updated to conform with the changes in TypeScript 5.7?
The text was updated successfully, but these errors were encountered:
Discussed in https://github.com/orgs/honojs/discussions/3700
Originally posted by marvinruder November 24, 2024
The code
runs as expected and shows no errors in TypeScript 5.6, but the following error is shown with TypeScript 5.7:
This is because a
Buffer
is no longer anArrayBuffer
(see https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/#typedarrays-are-now-generic-over-arraybufferlike, microsoft/TypeScript#59417 for details), and theData
type can only be astring
,ArrayBuffer
, orReadableStream
.Returning the
ArrayBuffer
within theBuffer
usingshows no type error, but leads to unexpected results, as responses are 8192 bytes long and contain lots of unrelated data. The reason for this is the shared memory pool from the
Buffer
module:What is the recommended way to use a Node.js
Buffer
as the body of a response? Do Hono’s types need to be updated to conform with the changes in TypeScript 5.7?The text was updated successfully, but these errors were encountered: