Uint8Array is really Uint8Array<ArrayBufferLike> and ArrayBufferLike can be ArrayBuffer, SharedArrayBuffer, and others.
In recent TypeScript versions this breaks on APIs that only accept ArrayBuffers since ArrayBufferLike could be a SharedArrayBuffer.
const foo = new Uint8Array() makes foo be Uint8Array<ArrayBuffer> (great!), but the return type of function foo (): Uint8Array { ... } is interpreted as Uint8Array<ArrayBufferLike> 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<ArrayBuffer> { ... } everywhere and in all supporting modules. Double ugh.
Uint8Arrayis reallyUint8Array<ArrayBufferLike>andArrayBufferLikecan beArrayBuffer,SharedArrayBuffer, and others.In recent TypeScript versions this breaks on APIs that only accept
ArrayBuffers sinceArrayBufferLikecould be aSharedArrayBuffer.const foo = new Uint8Array()makesfoobeUint8Array<ArrayBuffer>(great!), but the return type offunction foo (): Uint8Array { ... }is interpreted asUint8Array<ArrayBufferLike>so might be aSharedArrayBufferwhich breaks APIs likenew Blob([arr])in TypeScript 5.9.x. Ugh.It seems we need to change
function foo (): Uint8Array { ... }tofunction foo (): Uint8Array<ArrayBuffer> { ... }everywhere and in all supporting modules. Double ugh.