From a55ab31b74c68aee26c276c17db2b1eb3db3b99f Mon Sep 17 00:00:00 2001 From: Andrew MacDonald Date: Mon, 7 Oct 2019 16:30:52 -0700 Subject: [PATCH] fix: Use ListIterator for the remove predicate. (#38897) * Use ListIterator for the remove predicate. * generate fp --- types/lodash/common/array.d.ts | 6 +++--- types/lodash/fp.d.ts | 6 +++--- types/lodash/lodash-tests.ts | 8 -------- types/lodash/ts3.1/common/array.d.ts | 6 +++--- types/lodash/ts3.1/fp.d.ts | 6 +++--- types/lodash/ts3.1/lodash-tests.ts | 8 -------- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/types/lodash/common/array.d.ts b/types/lodash/common/array.d.ts index a16cad8301..bb128f3851 100644 --- a/types/lodash/common/array.d.ts +++ b/types/lodash/common/array.d.ts @@ -1858,7 +1858,7 @@ declare module "../index" { */ remove( array: List, - predicate?: ListIteratee + predicate?: ListIterator ): T[]; } @@ -1868,7 +1868,7 @@ declare module "../index" { */ remove( this: LoDashImplicitWrapper>, - predicate?: ListIteratee + predicate?: ListIterator ): LoDashImplicitWrapper; } @@ -1878,7 +1878,7 @@ declare module "../index" { */ remove( this: LoDashExplicitWrapper>, - predicate?: ListIteratee + predicate?: ListIterator ): LoDashExplicitWrapper; } diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index aebe99a611..e7b234f168 100644 --- a/types/lodash/fp.d.ts +++ b/types/lodash/fp.d.ts @@ -3740,12 +3740,12 @@ declare namespace _ { type LodashReject1x2 = (predicate: lodash.ValueIterateeCustom) => T[]; type LodashReject2x2 = (predicate: lodash.ValueIterateeCustom) => Array; interface LodashRemove { - (predicate: lodash.ValueIteratee): LodashRemove1x1; + (predicate: (value: T) => lodash.NotVoid): LodashRemove1x1; (predicate: lodash.__, array: lodash.List): LodashRemove1x2; - (predicate: lodash.ValueIteratee, array: lodash.List): T[]; + (predicate: (value: T) => lodash.NotVoid, array: lodash.List): T[]; } type LodashRemove1x1 = (array: lodash.List) => T[]; - type LodashRemove1x2 = (predicate: lodash.ValueIteratee) => T[]; + type LodashRemove1x2 = (predicate: (value: T) => lodash.NotVoid) => T[]; interface LodashRepeat { (n: number): LodashRepeat1x1; (n: lodash.__, string: string): LodashRepeat1x2; diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index f589cef369..d2d231d880 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -1074,23 +1074,15 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper _(list).remove(listIterator); // $ExpectType LoDashImplicitWrapper - _(list).remove(""); // $ExpectType LoDashImplicitWrapper - _(list).remove({ a: 42 }); // $ExpectType LoDashImplicitWrapper _.chain(list).remove(); // $ExpectType LoDashExplicitWrapper _.chain(list).remove(listIterator); // $ExpectType LoDashExplicitWrapper - _.chain(list).remove(""); // $ExpectType LoDashExplicitWrapper - _.chain(list).remove({ a: 42 }); // $ExpectType LoDashExplicitWrapper fp.remove(valueIterator, list); // $ExpectType AbcObject[] fp.remove(valueIterator)(list); // $ExpectType AbcObject[] - fp.remove("", list); // $ExpectType AbcObject[] - fp.remove({ a: 42 }, list); // $ExpectType AbcObject[] } // _.tail diff --git a/types/lodash/ts3.1/common/array.d.ts b/types/lodash/ts3.1/common/array.d.ts index 3831ba97ce..b234c7dc00 100644 --- a/types/lodash/ts3.1/common/array.d.ts +++ b/types/lodash/ts3.1/common/array.d.ts @@ -1115,19 +1115,19 @@ declare module "../index" { * @param predicate The function invoked per iteration. * @return Returns the new array of removed elements. */ - remove(array: List, predicate?: ListIteratee): T[]; + remove(array: List, predicate?: ListIterator): T[]; } interface Collection { /** * @see _.remove */ - remove(predicate?: ListIteratee): Collection; + remove(predicate?: ListIterator): Collection; } interface CollectionChain { /** * @see _.remove */ - remove(predicate?: ListIteratee): CollectionChain; + remove(predicate?: ListIterator): CollectionChain; } interface LoDashStatic { /** diff --git a/types/lodash/ts3.1/fp.d.ts b/types/lodash/ts3.1/fp.d.ts index 5ab08e2dc8..a3292955f8 100644 --- a/types/lodash/ts3.1/fp.d.ts +++ b/types/lodash/ts3.1/fp.d.ts @@ -3723,12 +3723,12 @@ declare namespace _ { type LodashReject1x2 = (predicate: lodash.ValueIterateeCustom) => T[]; type LodashReject2x2 = (predicate: lodash.ValueIterateeCustom) => Array; interface LodashRemove { - (predicate: lodash.ValueIteratee): LodashRemove1x1; + (predicate: (value: T) => lodash.NotVoid): LodashRemove1x1; (predicate: lodash.__, array: lodash.List): LodashRemove1x2; - (predicate: lodash.ValueIteratee, array: lodash.List): T[]; + (predicate: (value: T) => lodash.NotVoid, array: lodash.List): T[]; } type LodashRemove1x1 = (array: lodash.List) => T[]; - type LodashRemove1x2 = (predicate: lodash.ValueIteratee) => T[]; + type LodashRemove1x2 = (predicate: (value: T) => lodash.NotVoid) => T[]; interface LodashRepeat { (n: number): LodashRepeat1x1; (n: lodash.__, string: string): LodashRepeat1x2; diff --git a/types/lodash/ts3.1/lodash-tests.ts b/types/lodash/ts3.1/lodash-tests.ts index 927a8fae8c..e0d9e53512 100644 --- a/types/lodash/ts3.1/lodash-tests.ts +++ b/types/lodash/ts3.1/lodash-tests.ts @@ -1082,23 +1082,15 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain _.remove(list); // $ExpectType AbcObject[] _.remove(list, listIterator); // $ExpectType AbcObject[] - _.remove(list, ""); // $ExpectType AbcObject[] - _.remove(list, { a: 42 }); // $ExpectType AbcObject[] _(list).remove(); // $ExpectType Collection _(list).remove(listIterator); // $ExpectType Collection - _(list).remove(""); // $ExpectType Collection - _(list).remove({ a: 42 }); // $ExpectType Collection _.chain(list).remove(); // $ExpectType CollectionChain _.chain(list).remove(listIterator); // $ExpectType CollectionChain - _.chain(list).remove(""); // $ExpectType CollectionChain - _.chain(list).remove({ a: 42 }); // $ExpectType CollectionChain fp.remove(valueIterator, list); // $ExpectType AbcObject[] fp.remove(valueIterator)(list); // $ExpectType AbcObject[] - fp.remove("", list); // $ExpectType AbcObject[] - fp.remove({ a: 42 }, list); // $ExpectType AbcObject[] } // _.tail