Skip to content

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

Closed

Description

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.

Activity

  1. added
    Needs Investigation
    on May 24, 2017
  2. added
    Bug
    Domain: lib.d.ts
    and removed
    Needs Investigation
    on Feb 9, 2018
  3. added this to the milestone on Feb 9, 2018
  4. mhegazy commented on Feb 9, 2018

    @mhegazy
    Contributor

    PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

  5. lankaapura commented on Feb 9, 2018

    @lankaapura
    Contributor

    Mohamed Hegazy (@mhegazy) I'd like to work on this. Can you confirm following is correct?

    1. PR to Microsoft/TSJS-lib-generator to update dom.generated.d.ts, webworker.generated.d.ts and dom.es6.generated.d.ts
    2. updating method signatures of uniform* in lib.d.ts and lib.*.d.ts files except for above files
    3. Do I need to do any modifications in tests\lib\lib.d.ts?
  6. mhegazy commented on Feb 9, 2018

    @mhegazy
    Contributor

    PR to Microsoft/TSJS-lib-generator to update dom.generated.d.ts, webworker.generated.d.ts and dom.es6.generated.d.ts

    you want to update the input files like https://github.com/Microsoft/TSJS-lib-generator/blob/master/inputfiles/overridingTypes.json, then rerun the script. you then need to update baseline* with your local generated* and send a PR.

  7. lankaapura commented on Feb 10, 2018

    @lankaapura
    Contributor

    Thanks Mohamed Hegazy (@mhegazy), Create PR microsoft/TypeScript-DOM-lib-generator#368 for this. Let me know if there any issues.

  8. added
    Fixed in TSJS repo
    on Feb 10, 2018
  9. modified the milestones: , TypeScript 2.8 on Feb 10, 2018
  10. added
    Fixed
    on Feb 12, 2018
  11. removed
    Fixed in TSJS repo
    on Feb 12, 2018
  12. locked and limited conversation to collaborators on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDomain: lib.d.tsFixed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions