Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.d.ts: add missing TypedArray-from-iterable signatures #58188

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
72 changes: 63 additions & 9 deletions src/lib/es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,19 @@ interface Int8Array {
interface Int8ArrayConstructor {
new (elements: Iterable<number>): Int8Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int8Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array;
}

interface Uint8Array {
Expand All @@ -273,13 +279,19 @@ interface Uint8Array {
interface Uint8ArrayConstructor {
new (elements: Iterable<number>): Uint8Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint8Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array;
}

interface Uint8ClampedArray {
Expand All @@ -303,13 +315,19 @@ interface Uint8ClampedArray {
interface Uint8ClampedArrayConstructor {
new (elements: Iterable<number>): Uint8ClampedArray;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint8ClampedArray;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray;
}

interface Int16Array {
Expand All @@ -333,13 +351,19 @@ interface Int16Array {
interface Int16ArrayConstructor {
new (elements: Iterable<number>): Int16Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int16Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array;
}

interface Uint16Array {
Expand All @@ -361,13 +385,19 @@ interface Uint16Array {
interface Uint16ArrayConstructor {
new (elements: Iterable<number>): Uint16Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint16Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array;
}

interface Int32Array {
Expand All @@ -389,13 +419,19 @@ interface Int32Array {
interface Int32ArrayConstructor {
new (elements: Iterable<number>): Int32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Int32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array;
}

interface Uint32Array {
Expand All @@ -417,13 +453,19 @@ interface Uint32Array {
interface Uint32ArrayConstructor {
new (elements: Iterable<number>): Uint32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Uint32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array;
}

interface Float32Array {
Expand All @@ -445,13 +487,19 @@ interface Float32Array {
interface Float32ArrayConstructor {
new (elements: Iterable<number>): Float32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Float32Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array;
}

interface Float64Array {
Expand All @@ -473,11 +521,17 @@ interface Float64Array {
interface Float64ArrayConstructor {
new (elements: Iterable<number>): Float64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<number>): Float64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array;
}
24 changes: 20 additions & 4 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 {
readonly prototype: BigInt64Array;
new (length?: number): BigInt64Array;
new (array: Iterable<bigint>): BigInt64Array;
new (array: ArrayLike<bigint>): BigInt64Array;
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array;

/** The size in bytes of each element in the array. */
Expand All @@ -384,14 +385,21 @@ interface BigInt64ArrayConstructor {
*/
of(...items: bigint[]): BigInt64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<bigint>): BigInt64Array;
from(arrayLike: ArrayLike<bigint>): BigInt64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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>): BigInt64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array;
from<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => bigint, thisArg?: any): BigInt64Array;
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => bigint, thisArg?: any): BigInt64Array;
}

declare var BigInt64Array: BigInt64ArrayConstructor;
Expand Down Expand Up @@ -645,6 +653,7 @@ interface BigUint64ArrayConstructor {
readonly prototype: BigUint64Array;
new (length?: number): BigUint64Array;
new (array: Iterable<bigint>): BigUint64Array;
new (array: ArrayLike<bigint>): BigUint64Array;
new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array;

/** The size in bytes of each element in the array. */
Expand All @@ -656,14 +665,21 @@ interface BigUint64ArrayConstructor {
*/
of(...items: bigint[]): BigUint64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: Iterable<bigint>): BigUint64Array;
from(arrayLike: ArrayLike<bigint>): BigUint64Array;

/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @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<T>(arrayLike: Iterable<T>, mapfn: (v: T, k: number) => bigint, thisArg?: any): BigUint64Array;
from<T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => bigint, thisArg?: any): BigUint64Array;
}

declare var BigUint64Array: BigUint64ArrayConstructor;
Expand Down
Loading