ipfs / ipfs/aegir

Uint8Arrays are generic in recent TypeScript versions

Open
#1,847 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
105
Forks
62
PR merge metrics
No merged PRs in 30d

Description

`Uint8Array` is really `Uint8Array` and `ArrayBufferLike` can be `ArrayBuffer`, `SharedArrayBuffer`, and others.

In recent TypeScript versions this breaks on APIs that only accept `ArrayBuffer`s since `ArrayBufferLike` could be a `SharedArrayBuffer`.

`const foo = new Uint8Array()` makes `foo` be `Uint8Array` (great!), but the return type of `function foo (): Uint8Array { ... }` is interpreted as `Uint8Array` so might be a `SharedArrayBuffer` which breaks APIs like `new Blob([arr])` in TypeScript 5.9.x. Ugh.

It seems we need to change `function foo (): Uint8Array { ... }` to `function foo (): Uint8Array { ... }` everywhere and in all supporting modules. Double ugh.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.