Trying to come up with a suitable title for this question has been quite challenging.
The goal is to create a function that takes an Interface as a Generic and a string representing a key of that Interface. This function should return another function that can accept a parameter properly typed as (Interface[Key]).
export const createFunction = <T extends Record<string, any>>(
key: keyof T,
): (value: ?????) => void => (value) => {
// Do something with value
};
I experimented with a function type but couldn't get it to work
type Getter<T extends Record<string, any>> = <Key extends keyof T>(
key: Key,
) => (value: T[Key]) => void;