Skip to content

Commit 2727e54

Browse files
type map for objects as well as currently possible (preserves keys but not separate types)
microsoft/TypeScript#12393 (comment)
1 parent 5e3bedf commit 2727e54

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ramda.d.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,10 @@ declare namespace R {
889889
* Returns a new list, constructed by applying the supplied function to every element of the supplied list.
890890
*/
891891
map<T, U>(fn: (x: T) => U, list: T[]): U[];
892-
map<T, U>(fn: (x: T) => U, obj: U): U;
893-
map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
894892
map<T, U>(fn: (x: T) => U): (list: T[]) => U[];
893+
map<T, V, M extends {[k: string]: T}>(fn: (value: T) => V, obj: M): {[K in keyof M]: V};
894+
map<T, V, M extends {[k: string]: T}>(fn: (value: T) => V): (obj: M) => {[K in keyof M]: V};
895+
map<T, U>(fn: (x: T) => U, obj: Functor<T>): Functor<U>; // used in functors
895896

896897
/**
897898
* The mapAccum function behaves like a combination of map and reduce.
@@ -911,10 +912,8 @@ declare namespace R {
911912
/**
912913
* Like mapObj, but but passes additional arguments to the predicate function.
913914
*/
914-
mapObjIndexed<K extends Prop, T, U, V extends Record<K, T>>(fn: (value: T, key: string, obj?: V) => U, obj: V): Record<K, U>;
915-
mapObjIndexed<K extends Prop, T, U, V extends Record<K, T>>(fn: (value: T, key: string, obj?: V) => U, obj: V): { [P in keyof V]: U(V[P]) /*T?*/ };
916-
mapObjIndexed<T, TResult, Item>(fn: (value: T, key: string, obj?: any) => TResult, obj: Item): { [P in keyof Item]: Item[P] };
917-
mapObjIndexed<T, TResult>(fn: (value: T, key: string, obj?: any) => TResult): (obj: any) => {[index:string]: TResult};
915+
mapObjIndexed<T, V, M extends {[k: string]: T}>(fn: (value: T, key: string, obj?: M) => V, obj: M): {[K in keyof M]: V};
916+
mapObjIndexed<T, V, M extends {[k: string]: T}>(fn: (value: T, key: string, obj?: M) => V): (obj: M) => {[K in keyof M]: V};
918917

919918
/**
920919
* Tests a regular expression agains a String

0 commit comments

Comments
 (0)