mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 06:40:35 +08:00
Merge pull request #26180 from rayhaneh/Ramda-differenceWith-Typing-Different-Lists
[ramda] Modified differenceWith typing to accept lists of different types
This commit is contained in:
6
types/ramda/index.d.ts
vendored
6
types/ramda/index.d.ts
vendored
@@ -523,9 +523,9 @@ declare namespace R {
|
||||
* Duplication is determined according to the value returned by applying the supplied predicate to two list
|
||||
* elements.
|
||||
*/
|
||||
differenceWith<T>(pred: (a: T, b: T) => boolean, list1: ReadonlyArray<T>, list2: ReadonlyArray<T>): T[];
|
||||
differenceWith<T>(pred: (a: T, b: T) => boolean): (list1: ReadonlyArray<T>, list2: ReadonlyArray<T>) => T[];
|
||||
differenceWith<T>(pred: (a: T, b: T) => boolean, list1: ReadonlyArray<T>): (list2: ReadonlyArray<T>) => T[];
|
||||
differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: ReadonlyArray<T1>, list2: ReadonlyArray<T2>): T1[];
|
||||
differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean): (list1: ReadonlyArray<T1>, list2: ReadonlyArray<T2>) => T1[];
|
||||
differenceWith<T1, T2>(pred: (a: T1, b: T2) => boolean, list1: ReadonlyArray<T1>): (list2: ReadonlyArray<T2>) => T1[];
|
||||
|
||||
/*
|
||||
* Returns a new object that does not contain a prop property.
|
||||
|
||||
@@ -1950,19 +1950,23 @@ class Rectangle {
|
||||
};
|
||||
|
||||
() => {
|
||||
function cmp(x: any, y: any) {
|
||||
function cmp1(x: any, y: any) {
|
||||
return x.a === y.a;
|
||||
}
|
||||
|
||||
function cmp2(x: any, y: any) {
|
||||
return x.a === y.b;
|
||||
}
|
||||
|
||||
const l1 = [{a: 1}, {a: 2}, {a: 3}];
|
||||
const l2 = [{a: 3}, {a: 4}];
|
||||
R.differenceWith(cmp, l1, l2); // => [{a: 1}, {a: 2}]
|
||||
const l3 = [{b: 3}, {b: 4}];
|
||||
R.differenceWith(cmp1, l1, l2); // => [{a: 1}, {a: 2}]
|
||||
|
||||
const differenceWithCurried1 = R.differenceWith(cmp);
|
||||
const differenceWithCurried1 = R.differenceWith(cmp1);
|
||||
differenceWithCurried1(l1, l2); // =>[{a: 1}, {a: 2}]
|
||||
|
||||
const differenceWithCurried2 = R.differenceWith(cmp, l1);
|
||||
differenceWithCurried2(l2); // =>[{a: 1}, {a: 2}]
|
||||
R.differenceWith(cmp2, l1, l3); // => [{a: 1}, {a: 2}]
|
||||
};
|
||||
|
||||
() => {
|
||||
|
||||
Reference in New Issue
Block a user