X Tutup
Skip to content

typings: rationalise TypedArray types#62174

Open
Renegade334 wants to merge 1 commit intonodejs:mainfrom
Renegade334:typings-typedarrays
Open

typings: rationalise TypedArray types#62174
Renegade334 wants to merge 1 commit intonodejs:mainfrom
Renegade334:typings-typedarrays

Conversation

@Renegade334
Copy link
Member

Adding a constructor helper type allows for some simplification, as well as a fix or two.

@Renegade334 Renegade334 force-pushed the typings-typedarrays branch from babfd90 to fe79fa3 Compare March 10, 2026 01:43
Copy link
Member

@watilde watilde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I verified a few things before approving:

TypedArrayConstructor definition — correctly added to globals.d.ts as a union of all 12 concrete constructor types, fully mirroring the existing TypedArray instance union.

Type precision of TypedArrayPrototype and TypedArrayPrototypeGetSymbolToStringTag — both actually improve on the old explicit unions. The previous hardcoded lists had 11 members and were missing Float16Array. The new derived forms (TypedArrayConstructor["prototype"] and TypedArray[typeof Symbol.toStringTag]) automatically include it, making the types more accurate.

readonly removal from TypedArrayOf's rest parameter — this is fine for two reasons. First, readonly on a rest parameter has no effect on the call site (spreading a readonly T[] into a non-readonly rest parameter is accepted by the type checker, as opposed to a regular array parameter like in TypedArrayOfApply, where readonly does matter to callers). Second, this is a .d.ts declaration file with no implementation body, and the underlying %TypedArray%.of doesn't mutate items anyway. The asymmetry with TypedArrayOfApply keeping readonly is intentional and correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup