Skip to content

Commit a63c1c8

Browse files
authored
Merge pull request #10027 from maiermic/type-guards-in-Array.prototype.filter
add Array.prototype.filter signature with type guard
2 parents 21736a1 + dbd8dd5 commit a63c1c8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/lib/es5.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,12 @@ interface ReadonlyArray<T> {
10601060
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
10611061
*/
10621062
map<U>(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => U, thisArg?: any): U[];
1063+
/**
1064+
* Returns the elements of an array that meet the condition specified in a callback function.
1065+
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
1066+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
1067+
*/
1068+
filter<S extends T>(callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => value is S, thisArg?: any): S[];
10631069
/**
10641070
* Returns the elements of an array that meet the condition specified in a callback function.
10651071
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.

0 commit comments

Comments
 (0)