I am seeking a solution to dynamically define a type based on an array of possibilities.
Within the provided map, the keys represent the type's name, while the corresponding values are arrays containing possible options for that type.
export const typeOptions = {
areaOfStudy: ["politics", "mathematics", "biology"],
ageRange: ["1821", "2225", "26plus"],
societyCategory: [
"Debate Society",
"Basketball Society",
"Football Society",
"3D Modelling Society",
],
}
I am seeking a way to automatically derive the following from the above object:
export type AreaOfStudy = "politics" | "mathematics" | "biology";
export type AgeRange = "1821" | "2225" | "26plus";
export type SocietyCategory =
| "Debate Society"
| "Basketball Society"
| "Football Society"
| "3D Modelling Society"
Does anyone have any ideas or suggestions on how I could achieve this?