From f05ea21c9dbbed879b0e90aa0173310ef7c0aab1 Mon Sep 17 00:00:00 2001 From: Andrew MacDonald Date: Wed, 9 Oct 2019 11:04:16 -0700 Subject: [PATCH] Revert "fix: Use ListIterator for the remove predicate. (#38897)" (#38987) This reverts commit a55ab31b74c68aee26c276c17db2b1eb3db3b99f. --- 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, 28 insertions(+), 12 deletions(-) diff --git a/types/lodash/common/array.d.ts b/types/lodash/common/array.d.ts index bb128f3851..a16cad8301 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?: ListIterator + predicate?: ListIteratee ): T[]; } @@ -1868,7 +1868,7 @@ declare module "../index" { */ remove( this: LoDashImplicitWrapper>, - predicate?: ListIterator + predicate?: ListIteratee ): LoDashImplicitWrapper; } @@ -1878,7 +1878,7 @@ declare module "../index" { */ remove( this: LoDashExplicitWrapper>, - predicate?: ListIterator + predicate?: ListIteratee ): LoDashExplicitWrapper; } diff --git a/types/lodash/fp.d.ts b/types/lodash/fp.d.ts index e7b234f168..aebe99a611 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: (value: T) => lodash.NotVoid): LodashRemove1x1; + (predicate: lodash.ValueIteratee): LodashRemove1x1; (predicate: lodash.__, array: lodash.List): LodashRemove1x2; - (predicate: (value: T) => lodash.NotVoid, array: lodash.List): T[]; + (predicate: lodash.ValueIteratee, array: lodash.List): T[]; } type LodashRemove1x1 = (array: lodash.List) => T[]; - type LodashRemove1x2 = (predicate: (value: T) => lodash.NotVoid) => T[]; + type LodashRemove1x2 = (predicate: lodash.ValueIteratee) => 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 d2d231d880..f589cef369 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -1074,15 +1074,23 @@ _.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 b234c7dc00..3831ba97ce 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?: ListIterator): T[]; + remove(array: List, predicate?: ListIteratee): T[]; } interface Collection { /** * @see _.remove */ - remove(predicate?: ListIterator): Collection; + remove(predicate?: ListIteratee): Collection; } interface CollectionChain { /** * @see _.remove */ - remove(predicate?: ListIterator): CollectionChain; + remove(predicate?: ListIteratee): CollectionChain; } interface LoDashStatic { /** diff --git a/types/lodash/ts3.1/fp.d.ts b/types/lodash/ts3.1/fp.d.ts index a3292955f8..5ab08e2dc8 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: (value: T) => lodash.NotVoid): LodashRemove1x1; + (predicate: lodash.ValueIteratee): LodashRemove1x1; (predicate: lodash.__, array: lodash.List): LodashRemove1x2; - (predicate: (value: T) => lodash.NotVoid, array: lodash.List): T[]; + (predicate: lodash.ValueIteratee, array: lodash.List): T[]; } type LodashRemove1x1 = (array: lodash.List) => T[]; - type LodashRemove1x2 = (predicate: (value: T) => lodash.NotVoid) => T[]; + type LodashRemove1x2 = (predicate: lodash.ValueIteratee) => 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 e0d9e53512..927a8fae8c 100644 --- a/types/lodash/ts3.1/lodash-tests.ts +++ b/types/lodash/ts3.1/lodash-tests.ts @@ -1082,15 +1082,23 @@ _.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