mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
[underscore] Fixes sortBy on chained array wrapper (#40417)
* underscore - Fix an issue where calling sortBy on a chained wrapper around Z[] claimed to return a Z. e.g. _.chain([1, 2, 3]).sortBy(x => -x).value() would claim to be of type number, not number[]. * underscore - Ensure length property is present on value of calling sortBy on chained, wrapped array. * underscore - Be more explicit that sortBy returns an array. That's its implementation behaviour, even if not provided with an array to begin with. * underscore - Revert unused generic type.
This commit is contained in:
Vendored
+2
-2
@@ -5306,13 +5306,13 @@ declare module _ {
|
||||
* Wrapped type `any[]`.
|
||||
* @see _.sortBy
|
||||
**/
|
||||
sortBy(iterator?: _.ListIterator<T, any>, context?: any): _Chain<T>;
|
||||
sortBy(iterator?: _.ListIterator<T, any>, context?: any): _Chain<T, T[]>;
|
||||
|
||||
/**
|
||||
* Wrapped type `any[]`.
|
||||
* @see _.sortBy
|
||||
**/
|
||||
sortBy(iterator: string, context?: any): _Chain<T>;
|
||||
sortBy(iterator: string, context?: any): _Chain<T, T[]>;
|
||||
|
||||
/**
|
||||
* Wrapped type `any[]`.
|
||||
|
||||
@@ -196,6 +196,11 @@ _.min(numbers);
|
||||
|
||||
_.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num));
|
||||
|
||||
_([1, 2, 3]).chain()
|
||||
.sortBy(x => -x)
|
||||
.sortBy(x => -x)
|
||||
.value().length;
|
||||
|
||||
_([1.3, 2.1, 2.4]).groupBy((e) => Math.floor(e));
|
||||
_.groupBy([1.3, 2.1, 2.4], (num) => Math.floor(num).toString());
|
||||
_.groupBy(['one', 'two', 'three'], 'length');
|
||||
|
||||
Reference in New Issue
Block a user