Closed
Description
Bug Report
π Search Terms
TypedArray
, ArrayBuffer
, Promise.then
, await
π Version & Regression Information
- This changed between versions v3.3.3333 and v3.5.1
β― Playground Link
Playground link with relevant code
π» Code
const array = new Uint8Array(await Promise.resolve().then(() => new ArrayBuffer(10)))
π Actual behavior
The above code throws the following error when passing to a TypedArray
an awaited ArrayBuffer
from a Promise
involving a then
call
No overload matches this call.
The last overload gave the following error.
Argument of type 'Iterable<number> | ArrayBuffer' is not assignable to parameter of type 'ArrayBuffer'.
Type 'Iterable<number>' is missing the following properties from type 'ArrayBuffer': byteLength, slice, [Symbol.toStringTag]
π Expected behavior
The code should work because the following will not throw an error as the follow examples don't throw an error (also in playground link):
// refactoring the arrayBuffer definition to a separate variable doesn't throw an error
const arrayBuffer = await Promise.resolve().then(() => new ArrayBuffer(10))
const array = new Uint8Array(arrayBuffer)
// without the "then" it doesn't throw an error
const array = new Uint8Array(Promise.resolve(new ArrayBuffer(10)))