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
functiongetArr(): Uint8Array{returnnewUint8Array(0)}letarr=newUint8Array(0)arr=getArr()// fails compilation with TS2322letarr2: Uint8Array=newUint8Array(0)arr2=getArr()// this is fine
🙁 Actual behavior
TS2322 is thrown during compilation.
🙂 Expected behavior
I should be able to assign a value of type Uint8Array to a variable initialised with the Uint8Array constructor without specifying extra generics or types.
Additional information about the issue
The compilation error is:
Type 'Uint8Array<ArrayBufferLike>' is not assignable to type 'Uint8Array<ArrayBuffer>'.
Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'.
Type 'SharedArrayBuffer' is missing the following properties from type 'ArrayBuffer': resizable, resize, detached, transfer, transferToFixedLength(2322)
🔎 Search Terms
uint8array
🕗 Version & Regression Information
ArrayBufferLike#59417⏯ Playground Link
https://www.typescriptlang.org/play/?target=11&ts=5.8.3#code/GYVwdgxgLglg9mABAcwKZQIICcuIBQCUAXIgKoxhQAc2WAhgJ6IDeAUIoluiFkmKgHcyFarUZ4ADAVYBfVqwA26RHRyIAvIn5DylGjnFTWq3JrSYcheUqgqcAJhK7RBppu3C9YhpOkn7GijotFZAA
💻 Code
🙁 Actual behavior
TS2322 is thrown during compilation.
🙂 Expected behavior
I should be able to assign a value of type
Uint8Arrayto a variable initialised with theUint8Arrayconstructor without specifying extra generics or types.Additional information about the issue
The compilation error is: