Skip to content
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

Wrong WebGLRenderingContext interface definition for pixelStorei #27542

Closed
SpaceIm opened this issue Oct 4, 2018 · 5 comments
Closed

Wrong WebGLRenderingContext interface definition for pixelStorei #27542

SpaceIm opened this issue Oct 4, 2018 · 5 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@SpaceIm
Copy link

SpaceIm commented Oct 4, 2018

TypeScript Version: 3.1.1

Search Terms:
WebGLRenderingContext
pixelStorei

Code

gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);

Expected behavior:
well compiled

Actual behavior:
TS2345: Argument of type 'true' is not assignable to parameter of type 'number'.

pixelStorei definition in lib.dom.d.ts (in 3.1-rc and 3.1.1) :

pixelStorei(pname: GLenum, param: GLint): void;

should be :

pixelStorei(pname: GLenum, param: GLint | GLboolean): void;

In 3.0.3, pixelStorei definition was :

pixelStorei(pname: number, param: number | boolean): void;
AVGP added a commit to AVGP/TypeScript that referenced this issue Oct 15, 2018
AVGP added a commit to AVGP/TSJS-lib-generator that referenced this issue Oct 15, 2018
@weswigham weswigham added Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet Bug A bug in TypeScript Help Wanted You can do this Good First Issue Well scoped, documented and has the green light and removed Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet labels Oct 16, 2018
@andrewvarga
Copy link

Out of curiosity, I wonder how this could creep back in a second time?
#13093

@dakom
Copy link

dakom commented Oct 31, 2018

What is the recommended workaround until this is fixed? Not sure how to override this locally..

davidmaceachern added a commit to davidmaceachern/TypeScript that referenced this issue Nov 18, 2018
Wrong WebGLRenderingContext interface definition for pixelStorei
@davidmaceachern
Copy link

Created a pull request to fix #28591.

@mofogasy
Copy link

@dakom as a workaround we use 0 for false and 1 for true, not a 100% sure though if it works correctly

@SpaceIm
Copy link
Author

SpaceIm commented Jan 23, 2019

@dakom as a workaround we use 0 for false and 1 for true, not a 100% sure though if it works correctly

It works, and you can also convert boolean to a number.

gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); // error TS2345
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); // ok
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +true); // ok

gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); // error TS2345
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0); // ok
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, +false); // ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

6 participants