lodash: Consider rest operator for intersectionBy (#36610)

This commit is contained in:
Fumiaki MATSUSHIMA 2019-07-09 01:59:01 +09:00 committed by Andrew Branch
parent 1d1a9e75db
commit a64e763292
4 changed files with 42 additions and 8 deletions

View File

@ -1205,6 +1205,11 @@ declare module "../index" {
array?: List<T> | null,
...values: Array<List<T>>
): T[];
/**
* @see _.intersectionBy
*/
intersectionBy<T>(...values: Array<List<T> | ValueIteratee<T>>): T[];
}
interface LoDashImplicitWrapper<TValue> {
@ -1240,10 +1245,10 @@ declare module "../index" {
/**
* @see _.intersectionBy
*/
intersectionBy<T>(
this: LoDashImplicitWrapper<List<T> | null | undefined>,
...values: Array<List<T>>
): LoDashImplicitWrapper<T[]>;
intersectionBy<T1, T2>(
this: LoDashImplicitWrapper<List<T1> | null | undefined>,
...values: Array<List<T2> | ValueIteratee<T1 | T2>>
): LoDashImplicitWrapper<T1[]>;
}
interface LoDashExplicitWrapper<TValue> {
@ -1279,10 +1284,10 @@ declare module "../index" {
/**
* @see _.intersectionBy
*/
intersectionBy<T>(
this: LoDashExplicitWrapper<List<T> | null | undefined>,
...values: Array<List<T>>
): LoDashExplicitWrapper<T[]>;
intersectionBy<T1, T2>(
this: LoDashExplicitWrapper<List<T1> | null | undefined>,
...values: Array<List<T2> | ValueIteratee<T1 | T2>>
): LoDashExplicitWrapper<T1[]>;
}
// intersectionWith

View File

@ -624,6 +624,11 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper<number
value; // $ExpectType AbcObject
return 1;
});
// $ExpectType AbcObject[]
_.intersectionBy(...[list], (value) => {
value; // $ExpectType AbcObject
return 0;
});
_.chain(list).intersectionBy(list); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
_.chain(list).intersectionBy(list, "a"); // $ExpectType LoDashExplicitWrapper<AbcObject[]>
@ -661,11 +666,21 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType LoDashExplicitWrapper<number
value; // $ExpectType T1 | T2
return {};
});
// $ExpectType LoDashImplicitWrapper<T1[]>
_([t1]).intersectionBy(...[[t2]], (value) => {
value; // $ExpectType T1 | T2
return {};
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).intersectionBy([t2], (value) => {
value; // $ExpectType T1 | T2
return {};
});
// $ExpectType LoDashExplicitWrapper<T1[]>
_.chain([t1]).intersectionBy(...[[t2]], (value) => {
value; // $ExpectType T1 | T2
return {};
});
}
// _.intersectionWith

View File

@ -713,6 +713,10 @@ declare module "../index" {
* @see _.intersectionBy
*/
intersectionBy<T>(array?: List<T> | null, ...values: Array<List<T>>): T[];
/**
* @see _.intersectionBy
*/
intersectionBy<T>(...values: Array<List<T> | ValueIteratee<T>>): T[];
}
interface Collection<T> {
/**

View File

@ -615,6 +615,11 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
value; // $ExpectType AbcObject
return 0;
});
// $ExpectType AbcObject[]
_.intersectionBy(...[list], (value) => {
value; // $ExpectType AbcObject
return 0;
});
_(list).intersectionBy(list); // $ExpectType Collection<AbcObject>
_(list).intersectionBy(list, "a"); // $ExpectType Collection<AbcObject>
@ -635,6 +640,11 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
value; // $ExpectType AbcObject
return null;
});
// $ExpectType CollectionChain<AbcObject>
_.chain(list).intersectionBy(...[list], (value) => {
value; // $ExpectType AbcObject
return null;
});
fp.intersectionBy("a", list, list); // $ExpectType AbcObject[]
fp.intersectionBy("a", list, list); // $ExpectType AbcObject[]