Microsoft/TypeScript

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

Open

#60 862 ouverte le 27 déc. 2024

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: lib.d.tsHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

⚙ 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>.

Guide contributeur