Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sampaioletti opened this issue Nov 7, 2019 · 4 comments
Closed

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

sampaioletti opened this issue Nov 7, 2019 · 4 comments

Comments

@sampaioletti
Copy link

sampaioletti commented Nov 7, 2019

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.

@MaxGraey
Copy link
Member

MaxGraey commented Nov 7, 2019

@jtenner it still problematic

@MaxGraey
Copy link
Member

MaxGraey commented Nov 7, 2019

But we could try something like this

@MaxGraey
Copy link
Member

MaxGraey commented Nov 7, 2019

Ok, final solution.

But that's little complicated. May be somebody know better?

@MaxGraey
Copy link
Member

Fixed in #939

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants