mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Added a missing use case for flatMap
This commit is contained in:
Vendored
+18
@@ -4780,6 +4780,13 @@ declare namespace _ {
|
||||
collection: List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
flatMap(
|
||||
collection: object | null | undefined
|
||||
): any[];
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
@@ -4820,6 +4827,7 @@ declare namespace _ {
|
||||
iteratee: object
|
||||
): boolean[];
|
||||
}
|
||||
type T234 = number[][0];
|
||||
|
||||
interface LoDashImplicitWrapper<TValue> {
|
||||
/**
|
||||
@@ -4827,6 +4835,11 @@ declare namespace _ {
|
||||
*/
|
||||
flatMap<T>(this: LoDashImplicitWrapper<List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined>): LoDashImplicitWrapper<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
flatMap(): LoDashImplicitWrapper<any[]>;
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
@@ -4872,6 +4885,11 @@ declare namespace _ {
|
||||
*/
|
||||
flatMap<T>(this: LoDashExplicitWrapper<List<Many<T>> | Dictionary<Many<T>> | NumericDictionary<Many<T>> | null | undefined>): LoDashExplicitWrapper<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
flatMap(): LoDashExplicitWrapper<any[]>;
|
||||
|
||||
/**
|
||||
* @see _.flatMap
|
||||
*/
|
||||
|
||||
@@ -4462,6 +4462,21 @@ namespace TestFlatMap {
|
||||
result = _(objNumericDictionary).chain().flatMap(['a', 42]);
|
||||
result = _(objNumericDictionary).chain().flatMap({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
interface SampleObject {
|
||||
bar: number;
|
||||
foo: string[];
|
||||
}
|
||||
const obj: SampleObject = {
|
||||
bar: 1,
|
||||
foo: [''],
|
||||
};
|
||||
|
||||
const result1: Array<string | number> = _.flatMap(obj);
|
||||
const result2: _.LoDashImplicitWrapper<Array<string | number>> = _(obj).flatMap();
|
||||
const result3: _.LoDashExplicitWrapper<Array<string | number>> = _.chain(obj).flatMap();
|
||||
}
|
||||
}
|
||||
|
||||
// _.flatMapDeep
|
||||
|
||||
Reference in New Issue
Block a user