google / google/closure-compiler

Should `new Uint8Array(arr)` take `ReadonlyArray<number>` ?

Open
#4,302 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Currently `TypedArray` constructors do not accept `ReadonlyArray` even though the `.from()` static method only requires `IArrayLike`. [Here is the constructor and the static method](https://github.com/google/closure-compiler/blob/c1e6f7dc87863d9491bc55b12380e08eb0e02216/externs/es6.js#L879-L906) for `Uint8Array` for instance. Is this intentional? Can we allow `ReadonlyArray` in the constructor?

If this is consistent with the intended typing and design, I will send a PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.