Skip to content

Shouldn't TypedArray<T>.wrap return TypedArray<T>Β #938

Closed
@sampaioletti

Description

@sampaioletti

static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): ArrayBufferView;

@MaxGraey looks like you changed this to return a ArrayBufferView in #865. So you dont get intellisense if you wrap a ArrayBuffer in a typed array unless you cast/assert it back.

let buf=new ArrayBuffer(32)
let arr=Uint8Array.wrap(buf) //<-type is ArrayBufferView
let l=arr.length //<-fails
let l=(arr as Uint8Array).length //<-works

I was going to PR but I figured i should ask if there was a reason first.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions