diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index cc9616f131..44ef2167ae 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1074,6 +1074,16 @@ declare namespace R { /** * Like mapObj, but but passes additional arguments to the predicate function. */ + mapObjIndexed( + fn: (value: T, key: string, obj?: { + [key: string]: T + }) => TResult, + obj: { + [key: string]: T + } + ): { + [key: string]: TResult + }; mapObjIndexed(fn: (value: T, key: string, obj?: any) => TResult, obj: any): { [index: string]: TResult }; mapObjIndexed(fn: (value: T, key: string, obj?: any) => TResult): (obj: any) => { [index: string]: TResult }; diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 32bae5fa0c..1b78af72b2 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -502,6 +502,20 @@ R.times(i, 5); R.mapObjIndexed(prependKeyAndDouble, values); // => { x: 'x2', y: 'y4', z: 'z6' } }); +(() => { + const testObject: { + [key: string]: Error + } = { + hello: new Error('hello'), + }; + const errorMessages = R.mapObjIndexed( + function test(value, key) { + // value should be inferred. + return value.message + String(key); + }, testObject); + console.log(errorMessages); +}); + (() => { const a: number[] = R.ap([R.multiply(2), R.add(3)], [1, 2, 3]); // => [2, 4, 6, 4, 5, 6] const b: number[][] = R.of([1]); // => [[1]]