Microsoft/TypeScript

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

オープン

#60,862 opened on 2024/12/27

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (13,395 件のフォーク)batch import
BugDomain: lib.d.tsHelp Wanted

Repository metrics

Stars
 (108,860 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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

コントリビューターガイド