mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-11 10:59:55 +08:00
[ramda]: Improve map definition
This commit is contained in:
2
types/ramda/index.d.ts
vendored
2
types/ramda/index.d.ts
vendored
@@ -919,6 +919,8 @@ declare namespace R {
|
||||
map<T, U>(fn: (x: T) => U, list: T[]): U[];
|
||||
map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
|
||||
map<T, U>(fn: (x: T) => U): (list: T[]) => U[];
|
||||
map<T extends object, U extends {[P in keyof T]: U[P]}>(fn: (x: T[keyof T]) => U[keyof T], obj: T): U;
|
||||
map<T extends object, U extends {[P in keyof T]: U[P]}>(fn: (x: T[keyof T]) => U[keyof T]): (obj: T) => U;
|
||||
|
||||
/**
|
||||
* The mapAccum function behaves like a combination of map and reduce.
|
||||
|
||||
@@ -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<A, A>(R.inc, {a: 1, b: 2});
|
||||
R.map<A, B>(R.toString, {a: 1, b: 2});
|
||||
|
||||
R.map<A, A>(R.inc)({a: 1, b: 2});
|
||||
R.map<A, B>(R.toString)({a: 1, b: 2});
|
||||
};
|
||||
|
||||
() => {
|
||||
let digits = ["1", "2", "3", "4"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user