Skip to content

Commit 18de6ac

Browse files
committed
feat: Uint32ArrayBuffer type, better docs for those
1 parent d31a952 commit 18de6ac

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

array.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,34 @@
1414
// which would incorrectly accept SharedArrayBuffer instances.
1515
// < TypeScript 5.7 doesn't support templates for Uint8Array.
1616
// So this type is defined as a workaround to evaluate to Uint8Array<ArrayBuffer> on all versions of TypeScript.
17+
18+
/**
19+
* This is `Uint8Array<ArrayBuffer>`
20+
* (as opposed to `Uint8Array<SharedArrayBuffer>` and `Uint8Array<ArrayBufferLike>`)
21+
* on TypeScript versions that support that distinction.
22+
*
23+
* On TypeScript < 5.7, this is just `Uint8Array`, as it's not a template there.
24+
*/
1725
export type Uint8ArrayBuffer = ReturnType<typeof Uint8Array.from>;
26+
27+
/**
28+
* This is `Uint16Array<ArrayBuffer>`
29+
* (as opposed to `Uint16Array<SharedArrayBuffer>` and `Uint16Array<ArrayBufferLike>`)
30+
* on TypeScript versions that support that distinction.
31+
*
32+
* On TypeScript < 5.7, this is just `Uint16Array`, as it's not a template there.
33+
*/
1834
export type Uint16ArrayBuffer = ReturnType<typeof Uint16Array.from>;
1935

36+
/**
37+
* This is `Uint32Array<ArrayBuffer>`
38+
* (as opposed to `Uint32Array<SharedArrayBuffer>` and `Uint32Array<ArrayBufferLike>`)
39+
* on TypeScript versions that support that distinction.
40+
*
41+
* On TypeScript < 5.7, this is just `Uint32Array`, as it's not a template there.
42+
*/
43+
export type Uint32ArrayBuffer = ReturnType<typeof Uint32Array.from>;
44+
2045
/**
2146
* Output format for typed array conversions
2247
*/

0 commit comments

Comments
 (0)