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

fix(cli/dts): add typings for Change Array by copy proposal #16499

Merged
merged 7 commits into from
Nov 2, 2022
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 243 additions & 1 deletion cli/dts/lib.esnext.array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,38 @@ interface Array<T> {
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): T[];

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: T, b: T) => number): T[];

/**
* Copies and elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @returns An array containing the elements that were deleted.
*/
toSpliced(start: number, deleteCount?: number): T[];
crowlKats marked this conversation as resolved.
Show resolved Hide resolved
crowlKats marked this conversation as resolved.
Show resolved Hide resolved
/**
* Copies and removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @param items Elements to insert into the array in place of the deleted elements.
* @returns An array containing the elements that were deleted.
*/
toSpliced<F>(start: number, deleteCount: number, ...items: F[]): (F | T)[];

with<F>(index: number, value: F): (F | T)[];
crowlKats marked this conversation as resolved.
Show resolved Hide resolved
}

interface ReadonlyArray<T> {
Expand All @@ -52,7 +84,7 @@ interface ReadonlyArray<T> {
*/
findLast<S extends T>(predicate: (this: void, value: T, index: number, obj: T[]) => value is S, thisArg?: any): S | undefined;
findLast(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): T | undefined;

/**
* Returns the index of the last element in the array where predicate is true, and -1
* otherwise.
Expand All @@ -63,6 +95,38 @@ interface ReadonlyArray<T> {
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): T[];

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if the first argument is less than the second argument, zero if they're equal, and a positive
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: T, b: T) => number): T[];

/**
* Copies and elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @returns An array containing the elements that were deleted.
*/
toSpliced(start: number, deleteCount?: number): any[];
/**
* Copies and removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @param items Elements to insert into the array in place of the deleted elements.
* @returns An array containing the elements that were deleted.
*/
toSpliced<F>(start: number, deleteCount: number, ...items: F[]): (F | T)[];

with<F>(index: number, value: F): (F | T)[];
}

interface Int8Array {
Expand All @@ -87,6 +151,22 @@ interface Int8Array {
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Int8Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Int8Array;

with(index: number, value: number): Int8Array;
}

interface Uint8Array {
Expand All @@ -111,6 +191,22 @@ interface Uint8Array {
* predicate. If it is not provided, undefined is used instead.
*/
findLastIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Uint8Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Uint8Array;

with(index: number, value: number): Uint8Array;
}

interface Uint8ClampedArray {
Expand All @@ -135,6 +231,22 @@ interface Uint8ClampedArray {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Uint8ClampedArray;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray;

with(index: number, value: number): Uint8ClampedArray;
}


Expand All @@ -160,6 +272,23 @@ interface Int16Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number;


/** Copies and reverses the elements in an array.*/
toReversed(): Int16Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Int16Array;

with(index: number, value: number): Int16Array;
}

interface Uint16Array {
Expand All @@ -184,6 +313,23 @@ interface Uint16Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number;


/** Copies and reverses the elements in an array.*/
toReversed(): Uint16Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Uint16Array;

with(index: number, value: number): Uint16Array;
}

interface Int32Array {
Expand All @@ -208,6 +354,22 @@ interface Int32Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Int32Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Int32Array;

with(index: number, value: number): Int32Array;
}

interface Uint32Array {
Expand All @@ -232,6 +394,22 @@ interface Uint32Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Uint32Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Uint32Array;

with(index: number, value: number): Uint32Array;
}

interface Float32Array {
Expand All @@ -256,6 +434,22 @@ interface Float32Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Float32Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Float32Array;

with(index: number, value: number): Float32Array;
}

interface Float64Array {
Expand All @@ -280,6 +474,22 @@ interface Float64Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number;

/** Copies and reverses the elements in an array.*/
toReversed(): Float64Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: number, b: number) => number): Float64Array;

with(index: number, value: number): Float64Array;
}

interface BigInt64Array {
Expand All @@ -304,6 +514,22 @@ interface BigInt64Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: bigint, index: number, obj: BigInt64Array) => boolean, thisArg?: any): bigint;

/** Copies and reverses the elements in an array.*/
toReversed(): BigInt64Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: bigint, b: bigint) => number | bigint): BigInt64Array;

with(index: number, value: number): BigInt64Array;
}

interface BigUint64Array {
Expand All @@ -328,4 +554,20 @@ interface BigUint64Array {
* predicate. If it is not provided, undefined is used instead.
*/
findIndexLast(predicate: (value: bigint, index: number, obj: BigUint64Array) => boolean, thisArg?: any): bigint;

/** Copies and reverses the elements in an array.*/
toReversed(): BigUint64Array;

/**
* Copies and sorts an array.
* @param compareFn Function used to determine the order of the elements. It is expected to return
* a negative value if first argument is less than second argument, zero if they're equal and a positive
* value otherwise. If omitted, the elements are sorted in ascending order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
*/
toSorted(compareFn?: (a: bigint, b: bigint) => number | bigint): BigUint64Array;

crowlKats marked this conversation as resolved.
Show resolved Hide resolved
with(index: number, value: number): BigUint64Array;
}