my goal is to create a string literal union type from an array in an object.
I know how to create a union type from an array, like so
const genderArr = ["female", "male"] as const;
type Gender = typeof genderArr[number]; // "female" | "male"
How can I achieve the same for an array inside of an object
const QuestionnaireOptions = {
GENDER_OPTIONS: ["female", "male"],
SIZE_OPTIONS: [
"s",
"m",
"l",
],
};
type Gender = ??
I could not find any resource / similar stackoverflow post so far.
Thanks for your time!