I'm building a function that needs to update one field of an object at a time.
this object is defined through an interface T.
interface T {
a: TypeA;
b: TypeB;
c: TypeC;
}
This should be the type signature of this function:
(key: keyof T, value: typeof T[key]) => void
This generates the error: 'key' refers to a value, but it is being used as a type here. Did you mean 'typeof key'?. IMO I did not mean typeof key, since typeof key would be any key of T, but I want the value attribute to be of type TypeA if key = a, etc.
How can I select the type of the corresponding key value of T?