Skip to content

ArrayBuffer is missing slice() method in lib.d.ts #310

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
philipbulley opened this issue Jul 30, 2014 · 4 comments
Closed

ArrayBuffer is missing slice() method in lib.d.ts #310

philipbulley opened this issue Jul 30, 2014 · 4 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@philipbulley
Copy link
Contributor

The ArrayBuffer docs on MDN and MSDN show the existence of ArrayBuffer.slice(). This is not currently represented in lib.d.ts (as of ef5ae6e on master).

Existing:

interface ArrayBuffer {
    /**
      * Read-only. The length of the ArrayBuffer (in bytes).
      */
    byteLength: number;
}

Suggested:

interface ArrayBuffer {
    /**
      * Read-only. The length of the ArrayBuffer (in bytes).
      */
    byteLength: number;

    /**
      * Returns a section of an ArrayBuffer.
      */
    slice(begin:number, end?:number): ArrayBuffer;
}
@RyanCavanaugh
Copy link
Member

This method is only supported on newer platforms; lib.d.ts is intentionally generated from a more broadly-supported subset of the API.

If you're using this method and your code only needs to run on newer runtimes, you can easily re-open the interface and add the method.

@lukehoban
Copy link
Member

IE11 (and other head browsers) support ArrayBuffer.prototype.slice. I believe elsewhere, lib.d.ts includes everything that's part of IE11. For example, lib.d.ts includes Map and Set types. Given that, shouldn't slice be added?

@philipbulley
Copy link
Contributor Author

lib.d.ts is intentionally generated from a more broadly-supported subset of the API

Just out of interest, how do the Typescript team determine this? I'm assuming there must be a set of agreed upon rules that an API feature is tested against, as opposed to one's opinion?

@RyanCavanaugh
Copy link
Member

Talked to @mhegazy about this; the ArrayBuffer and ArrayBufferView are in the small subset of things that aren't automatically generated, so we just missed this one.

@sophiajt sophiajt added this to the Community milestone Jul 31, 2014
@mhegazy mhegazy closed this as completed Aug 1, 2014
@mhegazy mhegazy added the Fixed label Aug 1, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

5 participants