Is there a way to create a type in TypeScript that includes only a subset of keys from an object? Consider the example object below:
const something = {
cannary: "yellow",
coyote: "brown",
fox: "red",
roses: "white",
tulipan: "purple",
palmera: "green"
}
If I define a type like this:
type Something = keyof typeof something
Autocomplete and type checking will work for all keys, but what if I want to restrict it to only certain keys like:
type Animal = keyof typeof {only cannary|coyote|fox}
Is this possible to achieve in TypeScript?