Microsoft/TypeScript

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

Open

#60,862 创建于 2024年12月27日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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

贡献者指南