mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-29 11:12:23 +08:00
Merge pull request #6602 from chrootsu/lodash-pluck
lodash: signatures of the method _.pluck have been changed
This commit is contained in:
+63
-4
@@ -2777,10 +2777,6 @@ module TestMap {
|
||||
}
|
||||
}
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
result = <string[]>_(stoogesAges).pluck('name').value();
|
||||
result = <string[]>_.pluck(stoogesAges, ['name']);
|
||||
|
||||
// _.partition
|
||||
result = <string[][]>_.partition<string>('abcd', (n) => n < 'c');
|
||||
result = <string[][]>_.partition<string>(['a', 'b', 'c', 'd'], (n) => n < 'c');
|
||||
@@ -2809,6 +2805,69 @@ result = <{a: number}[][]>_([{a: 1}, {a: 2}]).partition('a', 2).value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a').value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a', 2).value();
|
||||
|
||||
// _.pluck
|
||||
module TestPluck {
|
||||
interface SampleObject {
|
||||
d: {b: TResult}[];
|
||||
}
|
||||
|
||||
let array: SampleObject[];
|
||||
let list: _.List<SampleObject>;
|
||||
let dictionary: _.Dictionary<SampleObject>;
|
||||
|
||||
{
|
||||
let result: any[];
|
||||
|
||||
result = _.pluck<SampleObject>(array, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(array, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject>(list, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(list, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject>(dictionary, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(dictionary, ['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(array, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(array, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(list, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(list, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(dictionary, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(dictionary, ['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).pluck<TResult>('d.0.b');
|
||||
result = _(array).pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(list).pluck<TResult>('d.0.b');
|
||||
result = _(list).pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(dictionary).pluck<TResult>('d.0.b');
|
||||
result = _(dictionary).pluck<TResult>(['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().pluck<TResult>('d.0.b');
|
||||
result = _(array).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(list).chain().pluck<TResult>('d.0.b');
|
||||
result = _(list).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(dictionary).chain().pluck<TResult>('d.0.b');
|
||||
result = _(dictionary).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
}
|
||||
}
|
||||
|
||||
interface ABC {
|
||||
[index: string]: number;
|
||||
a: number;
|
||||
|
||||
Vendored
+51
-43
@@ -5291,49 +5291,6 @@ declare module _ {
|
||||
): LoDashExplicitArrayWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.pluck
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Retrieves the value of a specified property from all elements in the collection.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param property The property to pluck.
|
||||
* @return A new array of property values.
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: Array<T>,
|
||||
property: string|string[]): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: List<T>,
|
||||
property: string|string[]): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: Dictionary<T>,
|
||||
property: string|string[]): any[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<TResult>(
|
||||
property: string): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<TResult>(
|
||||
property: string): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.partition
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -5482,6 +5439,57 @@ declare module _ {
|
||||
pluckValue: string): LoDashImplicitArrayWrapper<TResult[]>;
|
||||
}
|
||||
|
||||
//_.pluck
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Gets the property value of path from all elements in collection.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param path The path of the property to pluck.
|
||||
* @return A new array of property values.
|
||||
*/
|
||||
pluck<T extends {}>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
path: StringRepresentable|StringRepresentable[]
|
||||
): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<T extends {}, TResult>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
path: StringRepresentable|StringRepresentable[]
|
||||
): TResult[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.reduce
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user