From f77d259e80400e34b600b348a4cc08960c492798 Mon Sep 17 00:00:00 2001 From: sgoll <1277035+sgoll@users.noreply.github.com> Date: Mon, 26 Feb 2018 18:10:55 +0100 Subject: [PATCH] [ramda] Add second type argument to eqBy to allow different codomain (#23926) * Add second type argument to eqBy to allow different codomain * Add test for new type argument * Resolve unreachable function overload --- types/ramda/index.d.ts | 7 +++---- types/ramda/ramda-tests.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 205df9f569..081a62cbd7 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -576,10 +576,9 @@ declare namespace R { * Takes a function and two values in its domain and returns true if the values map to the same value in the * codomain; false otherwise. */ - eqBy(fn: (a: T) => T, a: T, b: T): boolean; - eqBy(fn: (a: T) => T, a: T): (b: T) => boolean; - eqBy(fn: (a: T) => T): (a: T, b: T) => boolean; - eqBy(fn: (a: T) => T): (a: T) => (b: T) => boolean; + eqBy(fn: (a: T) => U, a: T, b: T): boolean; + eqBy(fn: (a: T) => U, a: T): (b: T) => boolean; + eqBy(fn: (a: T) => U): CurriedFunction2; /** * Reports whether two functions have the same value for the specified property. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 8aef1c65fc..c32ab72028 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -2136,6 +2136,14 @@ class Rectangle { const c: (a: any[]) => any[] = R.symmetricDifferenceWith(eqA)(l1); // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}] }; +() => { + const eqL = R.eqBy(s => s.length); + const l1 = ['bb', 'ccc', 'dddd']; + const l2 = ['aaa', 'bb', 'c']; + R.symmetricDifferenceWith(eqL, l1, l2); // => ['dddd', 'c'] + R.symmetricDifferenceWith(eqL)(l1, l2); // => ['dddd', 'c'] +}; + /***************************************************************** * String category */