-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I'm trying to figure out what the proper typings are for the Ramda cookbook method mapKeys so it will transpile without throwing an error due to typings on fn argument of the anonymous function.
Example
import * as R from 'ramda';
export const mapKeys = R.curry(
(fn: ???, obj: { [k: string]: any } | { [k: number]: any }) =>
R.fromPairs(
R.map(
R.adjust(fn, 0), // <--- Error: tried typings for `adjust`
R.toPairs(obj) // Fixed by referencing typings of `toPairs`
)
)
);Error
Error is on fn:
Argument of type '{}' is not assignable to parameter of type '(a: string) => string'. Type '{}' provides no match for the signature '(a: string): string'.
Description
As you would expect you can solve similar issues like with obj by referencing the toPairs typings of { [k: string]: any } | { [k: number]: any }, but I tried using the adjust typings for fn of (a: any) => any with no luck.
A similar typings error occurs for another Ramda cookbook method renameBy that also uses adjust, so I thought maybe this was a typings issue with adjust, but the example below works.
R.adjust((a: any): any => {
return 2;
}, 2);