Skip to content

Type arguments for WebGLRenderingContext.uniform*fv as ArrayLike<number> instead of number[] #14925

Closed
@jkieboom

Description

@jkieboom

The uniform*fv methods on WebGLRenderingContext currently accept a Float32Array | number[], however it would be nicer if they could accept Float32Array | ArrayLike<number>. The webgl specification gives two signatures for these methods, one accepting a Float32Array and another accepting a sequence<GLFloat>. Hence it doesn't require an actual array, just something that may be indexed. ArrayLike<number> seems like a better fit.

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)

Code

function applyUniforms(v: ArrayLike<number>) {
  // Cannot pass v to uniform4fv and friends
  gl.uniform4fv(location, v);
}

Expected behavior:

I expected that I could, the webgl specification does not require this to be an actual array, it says sequence<GLFloat>.

Actual behavior:

It refuses to compile and I need to cast v.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions