From e9ecb63b333c8154d839b956378db8a4d37d916f Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Fri, 7 Jul 2017 14:42:36 +0200 Subject: [PATCH] [ramda]: Improve map definition --- types/ramda/index.d.ts | 2 ++ types/ramda/ramda-tests.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index e30c95f8be..1697ff4341 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -919,6 +919,8 @@ declare namespace R { map(fn: (x: T) => U, list: T[]): U[]; map(fn: (x: T) => U, obj: Functor): Functor; // used in functors map(fn: (x: T) => U): (list: T[]) => U[]; + map(fn: (x: T[keyof T]) => U[keyof T], obj: T): U; + map(fn: (x: T[keyof T]) => U[keyof T]): (obj: T) => U; /** * The mapAccum function behaves like a combination of map and reduce. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 18a5ed4e7d..908c88828a 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -753,6 +753,24 @@ interface Obj { R.map((x: number) => x - 1, numberFunctor); // => "Hello World" }; +() => { + interface A { + a: number; + b: number; + } + + interface B { + a: string; + b: string; + } + + R.map(R.inc, {a: 1, b: 2}); + R.map(R.toString, {a: 1, b: 2}); + + R.map(R.inc)({a: 1, b: 2}); + R.map(R.toString)({a: 1, b: 2}); +}; + () => { let digits = ["1", "2", "3", "4"];