Added TResult generic to chainable _(...).pluck methods

This is needed because there is no way to cast the output in the middle of the chain.

This is not be done on _.pluck() methods because T cannot be inferred.  In other words, this:

    <number>_.pluck(objectArray, 'id');

or this:

    var id: number = _.pluck(objectArray, 'id');

is cleaner than this:

    _.pluck<IMyObjectInterface, number>(objectArray, 'id');
This commit is contained in:
Brian Zengel
2014-06-02 16:41:45 -04:00
parent 063c99482a
commit 0fad808e8d
+4 -4
View File
@@ -3548,16 +3548,16 @@ declare module _ {
/**
* @see _.pluck
**/
pluck<T extends {}>(
property: string): LoDashArrayWrapper<any>;
pluck<TResult>(
property: string): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.pluck
**/
pluck<T extends {}>(
property: string): LoDashArrayWrapper<any>;
pluck<TResult>(
property: string): LoDashArrayWrapper<TResult>;
}
//_.reduce