Skip to content

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

Closed

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.

Activity

  1. MaxGraey commented on Nov 7, 2019

    @MaxGraey
    Member
  2. MaxGraey commented on Nov 7, 2019

    @MaxGraey
    Member

    But we could try something like this

  3. MaxGraey commented on Nov 7, 2019

    @MaxGraey
    Member

    Ok, final solution.

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

  4. MaxGraey commented on Nov 16, 2019

    @MaxGraey
    Member

    Fixed in #939

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

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