I am trying to define a type where the favoriteFruit property's value must be an item in options array. Where the options array is dynamic/unknown (making it impossible to use union types "|").
const options = ["apple", "orange", "kiwi"]; // Dynamic list that can be modified in the future
type Person = {
name: string;
favoriteFruit: /* --- val in [...options] --- */
};
const personA:Person = {name: "Jack", favoriteFruit: "apple"}; // OK
const personB:Person = {name: "John", favoriteFruit: "orange"}; // OK
const personC:Person = {name: "Jane", favoriteFruit: "banana"}; // ERROR