Is it possible to restrict an interface field names according some enum (without pointing each value of enum as name)? For example:
enum childSumNames {
child_incoming_costs = "isv_child_incoming_costs",
child_est_revenue = "isv_child_est_revenue",
child_margin = "isv_child_margin",
}
/** Only field names from childSumNames enum are allowed */
interface IChildSumFieldMapper {
[key in childSumNames]: string // something like this (but it is incorrect syntax)...
/* instead of this:
* [childSumNames.child_incoming_costs]: string,
* [childSumNames.child_est_revenue]: string,
* [childSumNames.child_margin]: string, */
}
// The example of IChildSumFieldMapper instance
const item: IChildSumFieldMapper = {
[childSumNames.child_incoming_costs]: "isv_incomingcost",
[childSumNames.child_est_revenue]: "isv_estimatedrevenue",
[childSumNames.child_margin]: "isv_margin",
}