fix: Use ListIterator for the remove predicate. (#38897)

* Use ListIterator for the remove predicate.

* generate fp
This commit is contained in:
Andrew MacDonald 2019-10-07 16:30:52 -07:00 committed by Armando Aguirre
parent 6090a81c7d
commit a55ab31b74
6 changed files with 12 additions and 28 deletions

View File

@ -1858,7 +1858,7 @@ declare module "../index" {
*/
remove<T>(
array: List<T>,
predicate?: ListIteratee<T>
predicate?: ListIterator<T, NotVoid>
): T[];
}
@ -1868,7 +1868,7 @@ declare module "../index" {
*/
remove<T>(
this: LoDashImplicitWrapper<List<T>>,
predicate?: ListIteratee<T>
predicate?: ListIterator<T, NotVoid>
): LoDashImplicitWrapper<T[]>;
}
@ -1878,7 +1878,7 @@ declare module "../index" {
*/
remove<T>(
this: LoDashExplicitWrapper<List<T>>,
predicate?: ListIteratee<T>
predicate?: ListIterator<T, NotVoid>
): LoDashExplicitWrapper<T[]>;
}

View File

@ -3740,12 +3740,12 @@ declare namespace _ {
type LodashReject1x2<T> = (predicate: lodash.ValueIterateeCustom<T, boolean>) => T[];
type LodashReject2x2<T> = (predicate: lodash.ValueIterateeCustom<T[keyof T], boolean>) => Array<T[keyof T]>;
interface LodashRemove {
<T>(predicate: lodash.ValueIteratee<T>): LodashRemove1x1<T>;
<T>(predicate: (value: T) => lodash.NotVoid): LodashRemove1x1<T>;
<T>(predicate: lodash.__, array: lodash.List<T>): LodashRemove1x2<T>;
<T>(predicate: lodash.ValueIteratee<T>, array: lodash.List<T>): T[];
<T>(predicate: (value: T) => lodash.NotVoid, array: lodash.List<T>): T[];
}
type LodashRemove1x1<T> = (array: lodash.List<T>) => T[];
type LodashRemove1x2<T> = (predicate: lodash.ValueIteratee<T>) => T[];
type LodashRemove1x2<T> = (predicate: (value: T) => lodash.NotVoid) => T[];
interface LodashRepeat {
(n: number): LodashRepeat1x1;
(n: lodash.__, string: string): LodashRepeat1x2;

View File

@ -1074,23 +1074,15 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper<number
_.remove(list); // $ExpectType AbcObject[]
_.remove(list, listIterator); // $ExpectType AbcObject[]
_.remove(list, ""); // $ExpectType AbcObject[]
_.remove(list, { a: 42 }); // $ExpectType AbcObject[]
_(list).remove(); // $ExpectType LoDashImplicitWrapper<AbcObject[]>
_(list).remove(listIterator); // $ExpectType LoDashImplicitWrapper<AbcObject[]>
_(list).remove(""); // $ExpectType LoDashImplicitWrapper<AbcObject[]>
_(list).remove({ a: 42 }); // $ExpectType LoDashImplicitWrapper<AbcObject[]>
_.chain(list).remove(); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
_.chain(list).remove(listIterator); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
_.chain(list).remove(""); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
_.chain(list).remove({ a: 42 }); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
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

View File

@ -1115,19 +1115,19 @@ declare module "../index" {
* @param predicate The function invoked per iteration.
* @return Returns the new array of removed elements.
*/
remove<T>(array: List<T>, predicate?: ListIteratee<T>): T[];
remove<T>(array: List<T>, predicate?: ListIterator<T, NotVoid>): T[];
}
interface Collection<T> {
/**
* @see _.remove
*/
remove(predicate?: ListIteratee<T>): Collection<T>;
remove(predicate?: ListIterator<T, NotVoid>): Collection<T>;
}
interface CollectionChain<T> {
/**
* @see _.remove
*/
remove(predicate?: ListIteratee<T>): CollectionChain<T>;
remove(predicate?: ListIterator<T, NotVoid>): CollectionChain<T>;
}
interface LoDashStatic {
/**

View File

@ -3723,12 +3723,12 @@ declare namespace _ {
type LodashReject1x2<T> = (predicate: lodash.ValueIterateeCustom<T, boolean>) => T[];
type LodashReject2x2<T> = (predicate: lodash.ValueIterateeCustom<T[keyof T], boolean>) => Array<T[keyof T]>;
interface LodashRemove {
<T>(predicate: lodash.ValueIteratee<T>): LodashRemove1x1<T>;
<T>(predicate: (value: T) => lodash.NotVoid): LodashRemove1x1<T>;
<T>(predicate: lodash.__, array: lodash.List<T>): LodashRemove1x2<T>;
<T>(predicate: lodash.ValueIteratee<T>, array: lodash.List<T>): T[];
<T>(predicate: (value: T) => lodash.NotVoid, array: lodash.List<T>): T[];
}
type LodashRemove1x1<T> = (array: lodash.List<T>) => T[];
type LodashRemove1x2<T> = (predicate: lodash.ValueIteratee<T>) => T[];
type LodashRemove1x2<T> = (predicate: (value: T) => lodash.NotVoid) => T[];
interface LodashRepeat {
(n: number): LodashRepeat1x1;
(n: lodash.__, string: string): LodashRepeat1x2;

View File

@ -1082,23 +1082,15 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
_.remove(list); // $ExpectType AbcObject[]
_.remove(list, listIterator); // $ExpectType AbcObject[]
_.remove(list, ""); // $ExpectType AbcObject[]
_.remove(list, { a: 42 }); // $ExpectType AbcObject[]
_(list).remove(); // $ExpectType Collection<AbcObject>
_(list).remove(listIterator); // $ExpectType Collection<AbcObject>
_(list).remove(""); // $ExpectType Collection<AbcObject>
_(list).remove({ a: 42 }); // $ExpectType Collection<AbcObject>
_.chain(list).remove(); // $ExpectType CollectionChain<AbcObject>
_.chain(list).remove(listIterator); // $ExpectType CollectionChain<AbcObject>
_.chain(list).remove(""); // $ExpectType CollectionChain<AbcObject>
_.chain(list).remove({ a: 42 }); // $ExpectType CollectionChain<AbcObject>
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