I have an interface like this:
interface ProjectCostData {
purchasePrice: number;
propertyValue: number;
recentlyDamaged: boolean;
}
Now I want to create an interface like this dynamically based on the interface above:
interface ProjectCostDataWithSetters {
purchasePrice: number;
setPurchasePrice: Dispatch<SetStateAction<number>>;
propertyValue: number;
setPropertyValue: Dispatch<SetStateAction<number>>;
recentlyDamaged: boolean;
setRecentlyDamage: Dispatch<SetStateAction<boolean>>;
}
--> Map over the first interface and for each entry A add a new entry B with the key `set${entryKey}` and a type that can be derived from entry A.
Is this possible in TS?
Background: I have a backend based on OpenAPI that provides me the API structure as a .yaml file. I pass that file through a generator and receive interfaces and functions to talk to the API. In the frontend I am using react context to build a global state. I would like to build my global react context based on the output of the generator.