Skip to content

More specific data types - ArrayBuffer instead of ArrayBufferLike #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joshkel
Copy link

@joshkel joshkel commented Aug 4, 2025

By default, TypeScript interfaces like DataView and Uint8Array are used with the more generic ArrayBufferLike type, representing that they can work with either ArrayBuffer or SharedArrayBuffer. TypeScript 5.9 now uses stricter types for interfaces such as the DOM fetch method: a DOM BufferSource is now (correctly) marked as requiring ArrayBuffer, not SharedArrayBuffer. As a result of that change, trying to use a @msgpack/msgpack encode result with a fetch call will result in a type error. This change updates the types in the Encoder class to use ArrayBuffer instead of ArrayBufferLike, which reflects their implementation and prevents issues with the newer, stricter interfaces.

See microsoft/TypeScript#62168 for more info.

By default, TypeScript interfaces like `DataView` and `Uint8Array` are used with the more generic `ArrayBufferLike` type, representing that they can work with either `ArrayBuffer` or `SharedArrayBuffer`. TypeScript 5.9 now uses stricter types for interfaces such as the DOM `fetch` method: a DOM `BufferSource` is now (correctly) marked as requiring `ArrayBuffer`, not `SharedArrayBuffer`.  As a result of that change, trying to use a @msgpack/msgpack `encode` result with a `fetch` call will result in a type error. This change updates the types in the `Encoder` class to use `ArrayBuffer` instead of `ArrayBufferLike`, which reflects their implementation and prevents issues with the newer, stricter interfaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant