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

lib.dom: DOMatrix constructor accepts TypedArrays, not only Arrays. #60862

Open
trusktr opened this issue Dec 27, 2024 · 2 comments
Open

lib.dom: DOMatrix constructor accepts TypedArrays, not only Arrays. #60862

trusktr opened this issue Dec 27, 2024 · 2 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Dec 27, 2024

⚙ Compilation target

n/a

⚙ Library

lib.dom

Missing / Incorrect Definition

DOMMatrix and DOMMatrixReadonly constructors are typed as accepting only number[] but they also accept TypedArrays in all browsers.

The following code works in all browsers:

Sample Code

new DOMMatrix(new Float32Array(16))

Documentation Link

The MDN documentation doesn't really mention this detail, and the spec mentions a "sequence" which to me isn't very specific. Isn't a TypedArray a "sequence of numbers"?

Perhaps the type should probably be ArrayLike<number>.

@trusktr
Copy link
Contributor Author

trusktr commented Dec 27, 2024

Besides this, DOMMatrix has toFloat32Array and toFloat64Array methods, and not a toArray method. Makes sense to be able to pass typed arrays if it can also return typed arrays. I've also opened an issue with the spec to add toArray.

@Jamesernator
Copy link

The MDN documentation doesn't really mention this detail, and the spec mentions a "sequence" which to me isn't very specific. Isn't a TypedArray a "sequence of numbers"?

A sequence in WebIDL is just an iterable.

The lib generator seems to be missing emitting iterable signatures for constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants