mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 01:31:45 +00:00
Deduce return type from key in _.pluck
This commit is contained in:
Vendored
+3
-2
@@ -2,6 +2,7 @@
|
||||
// Project: http://underscorejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Josh Baldwin <https://github.com/jbaldwin>, Christopher Currens <https://github.com/ccurrens>, Cassey Lottman <https://github.com/clottman>, Ard Timmerman <https://github.com/confususs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
declare var _: _.UnderscoreStatic;
|
||||
export = _;
|
||||
@@ -553,9 +554,9 @@ declare module _ {
|
||||
* @param propertyName The property to look for on each element within `list`.
|
||||
* @return The list of elements within `list` that have the property `propertyName`.
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
pluck<T extends {}, K extends keyof T>(
|
||||
list: _.List<T>,
|
||||
propertyName: string): any[];
|
||||
propertyName: K): T[K][];
|
||||
|
||||
/**
|
||||
* Returns the maximum value in list.
|
||||
|
||||
@@ -520,7 +520,7 @@ function chain_tests() {
|
||||
let numberObjects = [{property: 'odd', value: 1}, {property: 'even', value: 2}, {property: 'even', value: 0}];
|
||||
let evenAndOddGroupedNumbers = _.chain(numberObjects)
|
||||
.groupBy('property')
|
||||
.mapObject((objects: any) => _.pluck(objects, 'value'))
|
||||
.mapObject((objects) => _.pluck(objects, 'value'))
|
||||
.value(); // { odd: [1], even: [0, 2] }
|
||||
|
||||
var matrixOfString : string[][] = _.chain({'foo' : '1', 'bar': '1'})
|
||||
|
||||
Reference in New Issue
Block a user