From 04246ca369a3f27cb3a9d7b7449dddbf9d5b31c3 Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Sat, 21 Oct 2017 10:14:28 -0400 Subject: [PATCH] Added a missing use case for flatMap --- types/lodash/index.d.ts | 18 ++++++++++++++++++ types/lodash/lodash-tests.ts | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 0969775149..6f06f9cd31 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -4780,6 +4780,13 @@ declare namespace _ { collection: List> | Dictionary> | NumericDictionary> | 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 { /** @@ -4827,6 +4835,11 @@ declare namespace _ { */ flatMap(this: LoDashImplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashImplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashImplicitWrapper; + /** * @see _.flatMap */ @@ -4872,6 +4885,11 @@ declare namespace _ { */ flatMap(this: LoDashExplicitWrapper> | Dictionary> | NumericDictionary> | null | undefined>): LoDashExplicitWrapper; + /** + * @see _.flatMap + */ + flatMap(): LoDashExplicitWrapper; + /** * @see _.flatMap */ diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 3fa2ae6325..36f5860b0e 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -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 = _.flatMap(obj); + const result2: _.LoDashImplicitWrapper> = _(obj).flatMap(); + const result3: _.LoDashExplicitWrapper> = _.chain(obj).flatMap(); + } } // _.flatMapDeep