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

WebGL IDL generated types should use ArrayLike<*> for sequence<*> #28198

Closed
jessevdk opened this issue Oct 29, 2018 · 13 comments · Fixed by microsoft/TypeScript-DOM-lib-generator#699
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@jessevdk
Copy link

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms: WebGL, idl, float32list

Code

const ctx: WebGLRenderingContext = null;
const value: ArrayLike<number> = [0, 1, 2];

ctx.uniform3fv(0, value);

Expected behavior: Compiles without errors (used to work in 3.0)

Actual behavior: Compiles with error since ArrayLike<number> isn't assignable to Float32Array nor number[]

Playground Link: http://www.typescriptlang.org/play/#src=const%20ctx%3A%20WebGLRenderingContext%20%3D%20null%3B%0D%0Aconst%20value%3A%20ArrayLike%3Cnumber%3E%20%3D%20%5B0%2C%201%2C%202%5D%3B%0D%0A%0D%0Actx.uniform3fv(0%2C%20value)%3B

Related Issues: Wrong WebGLRenderingContext interface definition for pixelStorei #27542

@weswigham weswigham added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Oct 29, 2018
@weswigham
Copy link
Member

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.

@saschanaz
Copy link
Contributor

As I wrote in microsoft/TypeScript-DOM-lib-generator#592, Web IDL sequence requires iterator support but ArrayLike does not.

@weswigham
Copy link
Member

Iterable aughta be correct then, right?

@saschanaz
Copy link
Contributor

Yes, but unfortunately we cannot use Iterable because of es3/5 compatibility. (#23610)

@saschanaz
Copy link
Contributor

Maybe we still can add overloads via dom.es6.d.ts in this case.

@weswigham
Copy link
Member

Aye, that's what I was thinking. The es6 Dom lib seems like just the place for an overload like this.

@saschanaz
Copy link
Contributor

Oh, I just remembered that I opened an issue exactly for this purpose. microsoft/TypeScript-DOM-lib-generator#443

I can start working on this if the team agrees.

@Istar-Eldritch
Copy link

That makes more sense @saschanaz.
Does that make microsoft/TypeScript-DOM-lib-generator#592 obsolete in favour the general sequence override approach? Or should we keep the dom.generated.d.ts with number[]?

Also, does this change the scope to a more general approach? Should all number sequences in dom.generated.d.ts be overrided to number[]?

@saschanaz
Copy link
Contributor

We should keep existing number[] so that ES5 can keep passing arrays.

Should all number sequences in dom.generated.d.ts be overrided to number[]?

I'm not sure I understand. sequence<number> is already being translated into number[].

@Istar-Eldritch
Copy link

Istar-Eldritch commented Oct 30, 2018

I'm not familiar with the codebase so I'm probably missing something.

The baselines defines only Float32Array which doesn't accept number[]. Reference

If the translation to number[] is done already, where is it? Otherwise, It's your intention to do translation to number[] as part of microsoft/TypeScript-DOM-lib-generator#443?

@saschanaz
Copy link
Contributor

But L15924 doesn't contains Float32Array? If you mean Float32List, it's a union type of Float32Array and number[].

@Istar-Eldritch
Copy link

Istar-Eldritch commented Nov 1, 2018

@saschanaz true, sorry for messing things up. I was indeed mixing Float32List with FLoat32Array. @weswigham based on the evidence from @saschanaz, should we assume then that this issue is not achievable and close it?

@saschanaz
Copy link
Contributor

I would suggest you changing the title: ArrayLike -> Iterable.

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 Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants