Skip to content

Commit

Permalink
Add non-generic fallback overloads for TypedArray constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Jan 8, 2025
1 parent 717d05c commit 1957fed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/es2020.bigint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ interface BigInt64ArrayConstructor {
new (length?: number): BigInt64Array<ArrayBuffer>;
new (array: ArrayLike<bigint> | Iterable<bigint>): BigInt64Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): BigInt64Array<TArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): BigInt64Array<ArrayBuffer>;
new (array: ArrayLike<bigint> | ArrayBuffer): BigInt64Array<ArrayBuffer>;

/** The size in bytes of each element in the array. */
Expand Down Expand Up @@ -650,6 +651,7 @@ interface BigUint64ArrayConstructor {
new (length?: number): BigUint64Array<ArrayBuffer>;
new (array: ArrayLike<bigint> | Iterable<bigint>): BigUint64Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): BigUint64Array<TArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): BigUint64Array<ArrayBuffer>;
new (array: ArrayLike<bigint> | ArrayBuffer): BigUint64Array<ArrayBuffer>;

/** The size in bytes of each element in the array. */
Expand All @@ -667,8 +669,8 @@ interface BigUint64ArrayConstructor {
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: ArrayLike<bigint>): BigUint64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array;
from(arrayLike: ArrayLike<bigint>): BigUint64Array<ArrayBuffer>;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array<ArrayBuffer>;
}
declare var BigUint64Array: BigUint64ArrayConstructor;

Expand Down
9 changes: 9 additions & 0 deletions src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ interface Int8ArrayConstructor {
new (array: ArrayLike<number>): Int8Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Int8Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Int8Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -2385,6 +2386,7 @@ interface Uint8ArrayConstructor {
new (array: ArrayLike<number>): Uint8Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Uint8Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Uint8Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -2666,6 +2668,7 @@ interface Uint8ClampedArrayConstructor {
new (array: ArrayLike<number>): Uint8ClampedArray<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Uint8ClampedArray<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -2946,6 +2949,7 @@ interface Int16ArrayConstructor {
new (array: ArrayLike<number>): Int16Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Int16Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Int16Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -3227,6 +3231,7 @@ interface Uint16ArrayConstructor {
new (array: ArrayLike<number>): Uint16Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Uint16Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Uint16Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -3507,6 +3512,7 @@ interface Int32ArrayConstructor {
new (array: ArrayLike<number>): Int32Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Int32Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Int32Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -3787,6 +3793,7 @@ interface Uint32ArrayConstructor {
new (array: ArrayLike<number>): Uint32Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Uint32Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Uint32Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -4068,6 +4075,7 @@ interface Float32ArrayConstructor {
new (array: ArrayLike<number>): Float32Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Float32Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Float32Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down Expand Up @@ -4349,6 +4357,7 @@ interface Float64ArrayConstructor {
new (array: ArrayLike<number>): Float64Array<ArrayBuffer>;
new <TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(buffer: TArrayBuffer, byteOffset?: number, length?: number): Float64Array<TArrayBuffer>;
new (array: ArrayLike<number> | ArrayBuffer): Float64Array<ArrayBuffer>;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array<ArrayBuffer>;

/**
* The size in bytes of each element in the array.
Expand Down

0 comments on commit 1957fed

Please sign in to comment.