From 3340bc773cce7a0a4e407f95e4dddedaef249b85 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 30 Oct 2017 14:28:43 -0400 Subject: [PATCH 1/2] use typescript Pick<> to improve _.pick typings --- types/lodash/index.d.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index f1685af04f..1da7b79201 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -13908,10 +13908,30 @@ declare namespace _ { * _.pick(object, ['a', 'c']); * // => { 'a': 1, 'c': 3 } */ - pick( + pick( + object: T | null | undefined, + ...props: U[] + ): Pick; + + pick( + object: T | null | undefined, + props: U[] + ): Pick; + + pick( + object: T | null | undefined, + props: PropertyPath[] + ): PartialObject; + + pick( object: T | null | undefined, ...props: PropertyPath[] ): PartialObject; + + pick( + object: T | null | undefined, + ...props: PropertyPath[] + ): Pick; } interface LoDashImplicitWrapper { From 9c04d194944fe34e78ecdf025fdf23cc3776ad02 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 30 Oct 2017 22:16:24 -0400 Subject: [PATCH 2/2] remove extra overloads for _.pick --- types/lodash/index.d.ts | 19 ++----------------- types/lodash/lodash-tests.ts | 6 ++++++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 1da7b79201..0d65a0dfaa 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -13910,28 +13910,13 @@ declare namespace _ { */ pick( object: T | null | undefined, - ...props: U[] - ): Pick; - - pick( - object: T | null | undefined, - props: U[] + ...props: Array> ): Pick; - pick( - object: T | null | undefined, - props: PropertyPath[] - ): PartialObject; - pick( object: T | null | undefined, ...props: PropertyPath[] - ): PartialObject; - - pick( - object: T | null | undefined, - ...props: PropertyPath[] - ): Pick; + ): PartialDeep; } interface LoDashImplicitWrapper { diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index c7fb313dec..2c04cacfce 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -11183,6 +11183,12 @@ namespace TestPick { result = _.pick(obj, ['b', 1], 0, 'a'); } + { + let result: Pick; + result = _.pick(obj, 'a', 'b'); + result = _.pick(obj, ['a', 'b']); + } + { let result: _.LoDashImplicitWrapper>;