diff --git a/types/lodash/common/collection.d.ts b/types/lodash/common/collection.d.ts index d8ddc97197..eae4fb7018 100644 --- a/types/lodash/common/collection.d.ts +++ b/types/lodash/common/collection.d.ts @@ -1777,6 +1777,10 @@ declare module "../index" { * @param callback The function called per iteration. * @return Returns the array of grouped elements. **/ + partition( + collection: List | null | undefined, + callback: ValueIteratorTypeGuard + ): [U[], Array>]; partition( collection: List | null | undefined, callback: ValueIteratee @@ -1795,6 +1799,10 @@ declare module "../index" { /** * @see _.partition */ + partition( + this: LoDashImplicitWrapper | null | undefined>, + callback: ValueIteratorTypeGuard + ): LoDashImplicitWrapper<[U[], Array>]>; partition( this: LoDashImplicitWrapper | null | undefined>, callback: ValueIteratee @@ -1813,6 +1821,10 @@ declare module "../index" { /** * @see _.partition */ + partition( + this: LoDashExplicitWrapper | null | undefined>, + callback: ValueIteratorTypeGuard + ): LoDashExplicitWrapper<[U[], Array>]>; partition( this: LoDashExplicitWrapper | null | undefined>, callback: ValueIteratee diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index 023758b4c3..32f833b5eb 100644 --- a/types/lodash/fp.d.ts +++ b/types/lodash/fp.d.ts @@ -2705,15 +2705,21 @@ declare namespace _ { type LodashPartialRight27x1 = (args: ReadonlyArray) => (...args: any[]) => any; type LodashPartialRight27x2 = (func: (...args: any[]) => any) => (...args: any[]) => any; interface LodashPartition { - (callback: lodash.ValueIteratee): LodashPartition1x1; + (callback: lodash.ValueIteratorTypeGuard): LodashPartition1x1; (callback: lodash.__, collection: lodash.List | null | undefined): LodashPartition1x2; + (callback: lodash.ValueIteratorTypeGuard, collection: lodash.List | null | undefined): [U[], Array>]; + (callback: lodash.ValueIteratee): LodashPartition2x1; (callback: lodash.ValueIteratee, collection: lodash.List | null | undefined): [T[], T[]]; - (callback: lodash.__, collection: T | null | undefined): LodashPartition2x2; + (callback: lodash.__, collection: T | null | undefined): LodashPartition3x2; (callback: lodash.ValueIteratee, collection: T | null | undefined): [Array, Array]; } - type LodashPartition1x1 = (collection: lodash.List | object | null | undefined) => [T[], T[]]; - type LodashPartition1x2 = (callback: lodash.ValueIteratee) => [T[], T[]]; - type LodashPartition2x2 = (callback: lodash.ValueIteratee) => [Array, Array]; + type LodashPartition1x1 = (collection: lodash.List | null | undefined) => [U[], Array>]; + interface LodashPartition1x2 { + (callback: lodash.ValueIteratorTypeGuard): [U[], Array>]; + (callback: lodash.ValueIteratee): [T[], T[]]; + } + type LodashPartition2x1 = (collection: lodash.List | object | null | undefined) => [T[], T[]]; + type LodashPartition3x2 = (callback: lodash.ValueIteratee) => [Array, Array]; interface LodashPath { (path: TKey | [TKey]): LodashPath1x1; (path: lodash.__, object: TObject): LodashPath1x2; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index 0e2b97fdf3..be0078cddb 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -2794,6 +2794,8 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper { value; // $ExpectType any @@ -2809,6 +2811,8 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper typeof value === 'number'); // $ExpectType LoDashImplicitWrapper<[any[], any[]]> _(anything).partition((value) => { @@ -2825,6 +2829,8 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper + _(mixedArray).partition((value): value is number => typeof value === 'number'); // $ExpectType LoDashExplicitWrapper<[any[], any[]]> _.chain(anything).partition((value) => { @@ -2841,6 +2847,8 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper + _.chain(mixedArray).partition((value): value is number => typeof value === 'number'); // $ExpectType [any[], any[]] fp.partition((value) => { @@ -2859,6 +2867,8 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper typeof value === 'number', mixedArray); } // _.reduce diff --git a/types/lodash/readme.md b/types/lodash/readme.md index e605e30784..4d1e9b03ba 100644 --- a/types/lodash/readme.md +++ b/types/lodash/readme.md @@ -47,9 +47,9 @@ - In general, no. - If the wrapper functions are almost copies of the original functions, shouldn't we auto-generate them like we do for `lodash/fp`? - Good idea! If you have time, submit a PR. -- When I ran `npm run lint lodash`, I got an error that loks like `<--- Last few GCs --->`. +- When I ran `npm run lint lodash`, I got an error that looks like `<--- Last few GCs --->`. - Yeah, this error is really annoying. It means that node.js ran out of memory before it could run all of your tests. - - If you see somthing like `Test with 2.6` before that error, it means that there's an error in an older version of typescript. + - If you see something like `Test with 2.6` before that error, it means that there's an error in an older version of typescript. The hard part is figuring out what the error is. - The general procedure for diagnosing these errors is: 1. Delete half of the tests in `lodash-tests.ts` (either the top half or the bottom half). @@ -57,6 +57,6 @@ 2. Run `npm run lint lodash`. 3. If it succeeds, add that half back and delete the other half. 4. If it fails with a GC error, delete half of the remaining tests. - - Note: If both halfs succeed on their own, then the tests are probably just consuming too much memory. Try simplifying them until they pass. + - Note: If both halves succeed on their own, then the tests are probably just consuming too much memory. Try simplifying them until they pass. 5. Repeat steps 1-4 until it gives you the real error message. Usually it's something obscure that only happens in TS 2.3/T.4, so commenting/modifying the test is usually the best solution. diff --git a/types/lowdb/_lodash.d.ts b/types/lowdb/_lodash.d.ts index c24e2f1c08..17cdf43548 100644 --- a/types/lowdb/_lodash.d.ts +++ b/types/lowdb/_lodash.d.ts @@ -648,6 +648,10 @@ declare module "./index" { iteratees?: _.Many<_.ObjectIteratee>, orders?: _.Many ): LoDashExplicitSyncWrapper>; + partition( + this: LoDashExplicitSyncWrapper<_.List | null | undefined>, + callback: _.ValueIteratorTypeGuard + ): LoDashExplicitSyncWrapper<[U[], Array>]>; partition( this: LoDashExplicitSyncWrapper<_.List | null | undefined>, callback: _.ValueIteratee @@ -2244,6 +2248,10 @@ declare module "./index" { iteratees?: _.Many<_.ObjectIteratee>, orders?: _.Many ): LoDashExplicitAsyncWrapper>; + partition( + this: LoDashExplicitAsyncWrapper<_.List | null | undefined>, + callback: _.ValueIteratorTypeGuard + ): LoDashExplicitAsyncWrapper<[U[], Array>]>; partition( this: LoDashExplicitAsyncWrapper<_.List | null | undefined>, callback: _.ValueIteratee