I'm working on a function that returns another function, and I need some guidance:
fn: <T extends Object>(key: keyof T) => (value: ???) => void
I want the type of ???
to be determined by the type of instanceOfT[key]
. For instance, in the case of T={name: string; age: number}
, I expect fn('name')
to output (value: string) => void
and for fn('age')
to output (value: number) => void
Do you think this is achievable?