From d85cf6b138ec075dc73e00b7a4c9406c97fb485c Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Mon, 5 Feb 2018 19:16:41 +0200 Subject: [PATCH] tests for _.pick --- types/lodash/lodash-tests.ts | 69 ++++++++++++++---------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 18a179c4c6..ca33017323 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -11800,52 +11800,35 @@ namespace TestOmitBy { // _.pick namespace TestPick { - let obj1: AbcObject | null | undefined = anything; - let obj2: AbcObject = anything; + const obj1: AbcObject | null | undefined = anything; + const obj2: AbcObject = anything; + const readonlyArray: ReadonlyArray = ['a', 'b']; + const literalsArray = ['a' as 'a', 'b' as 'b']; + const roLiteralsArray: ReadonlyArray<'a' | 'b'> = literalsArray; - { - let result: Partial; + _.pick(obj1, 'a'); // $ExpectType PartialDeep + _.pick(obj1, 0, 'a'); // $ExpectType PartialDeep + _.pick(obj1, ['b', 1], 0, 'a'); // $ExpectType PartialDeep + _.pick(obj1, readonlyArray); // $ExpectType PartialDeep + _.pick(obj2, 'a', 'b'); // $ExpectType Pick + _.pick(obj2, literalsArray); // $ExpectType Pick + _.pick(obj2, roLiteralsArray); // $ExpectType Pick - result = _.pick(obj1, 'a'); - result = _.pick(obj1, 0, 'a'); - result = _.pick(obj1, ['b', 1], 0, 'a'); - } + _(obj1).pick('a'); // $ExpectType LoDashImplicitWrapper> + _(obj1).pick(0, 'a'); // $ExpectType LoDashImplicitWrapper> + _(obj1).pick(['b', 1], 0, 'a'); // $ExpectType LoDashImplicitWrapper> + _(obj1).pick(readonlyArray); // $ExpectType LoDashImplicitWrapper> + _(obj2).pick('a', 'b'); // $ExpectType LoDashImplicitWrapper> + _(obj2).pick(literalsArray); // $ExpectType LoDashImplicitWrapper> + _(obj2).pick(roLiteralsArray); // $ExpectType LoDashImplicitWrapper> - { - let result: Pick; - result = _.pick(obj2, 'a', 'b'); - result = _.pick(obj2, ['a' as 'a', 'b' as 'b']); - } - - { - let result: _.LoDashImplicitWrapper>; - - result = _(obj1).pick('a'); - result = _(obj1).pick(0, 'a'); - result = _(obj1).pick(['b', 1], 0, 'a'); - } - - { - let result: _.LoDashImplicitWrapper>; - - result = _(obj2).pick('a', 'b'); - result = _(obj2).pick(['a' as 'a', 'b' as 'b']); - } - - { - let result: _.LoDashExplicitWrapper>; - - result = _(obj1).chain().pick('a'); - result = _(obj1).chain().pick(0, 'a'); - result = _(obj1).chain().pick(['b', 1], 0, 'a'); - } - - { - let result: _.LoDashExplicitWrapper>; - - result = _(obj2).chain().pick('a', 'b'); - result = _(obj2).chain().pick(['a' as 'a', 'b' as 'b']); - } + _.chain(obj1).pick('a'); // $ExpectType LoDashExplicitWrapper> + _.chain(obj1).pick(0, 'a'); // $ExpectType LoDashExplicitWrapper> + _.chain(obj1).pick(['b', 1], 0, 'a'); // $ExpectType LoDashExplicitWrapper> + _.chain(obj1).pick(readonlyArray); // $ExpectType LoDashExplicitWrapper> + _.chain(obj2).pick('a', 'b'); // $ExpectType LoDashExplicitWrapper> + _.chain(obj2).pick(literalsArray); // $ExpectType LoDashExplicitWrapper> + _.chain(obj2).pick(roLiteralsArray); // $ExpectType LoDashExplicitWrapper> } // _.pickBy