Update lodash/fp/filter to support string[].

This commit is contained in:
Max Bogue
2019-01-04 16:05:51 -06:00
parent 6537c15a28
commit 08319af8f7
4 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -215,7 +215,7 @@ declare module "../index" {
* @return Returns the new filtered array.
*/
filter(
collection: string | null | undefined,
collection: string | string[] | null | undefined,
predicate?: StringIterator<boolean>
): string[];
@@ -257,7 +257,7 @@ declare module "../index" {
* @see _.filter
*/
filter(
this: LoDashImplicitWrapper<string | null | undefined>,
this: LoDashImplicitWrapper<string | string[] | null | undefined>,
predicate?: StringIterator<boolean>
): LoDashImplicitWrapper<string[]>;
@@ -299,7 +299,7 @@ declare module "../index" {
* @see _.filter
*/
filter(
this: LoDashExplicitWrapper<string | null | undefined>,
this: LoDashExplicitWrapper<string | string[] | null | undefined>,
predicate?: StringIterator<boolean>
): LoDashExplicitWrapper<string[]>;
+3 -3
View File
@@ -918,8 +918,8 @@ declare namespace _ {
type LodashFill2x14<T, U> = (start: number) => lodash.List<T | U>;
interface LodashFilter {
(predicate: (value: string) => boolean): LodashFilter1x1;
(predicate: lodash.__, collection: string | null | undefined): LodashFilter1x2;
(predicate: (value: string) => boolean, collection: string | null | undefined): string[];
(predicate: lodash.__, collection: string | string[] | null | undefined): LodashFilter1x2;
(predicate: (value: string) => boolean, collection: string | string[] | null | undefined): string[];
<T, S extends T>(predicate: lodash.ValueIteratorTypeGuard<T, S>): LodashFilter2x1<T, S>;
<T>(predicate: lodash.__, collection: lodash.List<T> | null | undefined): LodashFilter2x2<T>;
<T, S extends T>(predicate: lodash.ValueIteratorTypeGuard<T, S>, collection: lodash.List<T> | null | undefined): S[];
@@ -930,7 +930,7 @@ declare namespace _ {
<T extends object, S extends T[keyof T]>(predicate: lodash.ValueIteratorTypeGuard<T[keyof T], S>, collection: T | null | undefined): S[];
<T extends object>(predicate: lodash.ValueIterateeCustom<T[keyof T], boolean>, collection: T | null | undefined): Array<T[keyof T]>;
}
type LodashFilter1x1 = (collection: string | null | undefined) => string[];
type LodashFilter1x1 = (collection: string | string[] | null | undefined) => string[];
type LodashFilter1x2 = (predicate: (value: string) => boolean) => string[];
type LodashFilter2x1<T, S> = (collection: lodash.List<T> | null | undefined) => S[];
interface LodashFilter2x2<T> {
+1
View File
@@ -1766,6 +1766,7 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper<number
fp.filter("", dictionary); // $ExpectType AbcObject[]
fp.filter({ a: 42 }, dictionary); // $ExpectType AbcObject[]
fp.filter(["a", 42], dictionary); // $ExpectType AbcObject[]
fp.filter(Boolean)(["a", "b"]); // $ExpectType string[]
// Test filtering with type guard
const a2: Array<string | number> | null | undefined = anything;
+2 -2
View File
@@ -459,7 +459,7 @@ declare module "./index" {
predicate?: _.ObjectIterateeCustom<T, boolean>
): LoDashExplicitSyncWrapper<boolean>;
filter(
this: LoDashExplicitSyncWrapper<string | null | undefined>,
this: LoDashExplicitSyncWrapper<string | string[] | null | undefined>,
predicate?: _.StringIterator<boolean>
): LoDashExplicitSyncWrapper<string[]>;
filter<T, S extends T>(
@@ -2055,7 +2055,7 @@ declare module "./index" {
predicate?: _.ObjectIterateeCustom<T, boolean>
): LoDashExplicitAsyncWrapper<boolean>;
filter(
this: LoDashExplicitAsyncWrapper<string | null | undefined>,
this: LoDashExplicitAsyncWrapper<string | string[] | null | undefined>,
predicate?: _.StringIterator<boolean>
): LoDashExplicitAsyncWrapper<string[]>;
filter<T, S extends T>(