If I have the following state type,
type State = {
currentPartnerId: number;
currentTime: string;
};
I am looking to create a new type with keys like getCurrentPartnerId
and values that are functions returning the corresponding key's value in State
.
For example:
type NewType = {
getCurrentParternerId: () => number;
getCurrentTime: () => string;
}
I attempted the following approach:
type Dict<T extends keyof State> = { [key in `get${Capitalize<T>}`]: () => State[T] }
However, this method requires providing a type argument which is something I would like to avoid...