A series of interfaces has been defined:
export interface FormData<T extends ControlData = any> {
[type: string]: T;
}
export type FormResult<T extends FormData> = {
[type in keyof T]: T[type];
};
export interface ControlData<T = any> {
value: T;
}
export interface ButtonSelectControlData<T> extends ControlData<T> {
query: string;
}
export interface RoutesAddCityData extends FormData {
cityId: ButtonSelectControlData<number>;
routeId: ControlData<number>;
}
When utilizing the FormResult function:
(data: FormResult<RoutesAddCityData>) => {
// ...
}
Upon inspection, it is noted that data.cityId
is of type
ButtonSelectControlData<number>
and data.routeId
is of type ControlData<number>
.
However, I am interested in seeing the type number in both cases. Is there a way to achieve this?