diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index aa84cad395..84d4edffce 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -15,7 +15,7 @@ declare namespace R { } interface Functor { - map(a: any): T; + map(fn: (t: T) => U): Functor; } interface ObjectIterator { diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 13aeb222f7..fa0c55d156 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -668,7 +668,7 @@ interface Obj { a: number; b: number }; const stringFunctor = { map: (fn: (c: number) => number) => { var chars = "Ifmmp!Xpsme".split(""); - return chars.map((char) => String.fromCharCode(fn(char.charCodeAt(0)))).join(""); + return chars.map((char) => String.fromCharCode(fn(char.charCodeAt(0)))).join("") as any; } }; R.map((x: number) => x-1, stringFunctor); // => "Hello World" @@ -1985,3 +1985,10 @@ class Why { R.intersperse(0, [1, 2]); //=> [1, 0, 2] R.intersperse(0, [1]); //=> [1] } + +{ + const functor = { + map: (fn: (x: string) => string) => functor + } + R.map(x => x.trim(), functor) +}