I have something like this:
Obviously this is an overly minimal example so the question of why I would want to do these types specifically is irrelevant.
type Bird = { kind: "bird" }
type Fish = { kind: "fish" }
const zoo = {
flamingo: { kind: "bird" },
hawk: { kind: "bird" },
chicken: { kind: "bird" },
guppy: { kind: "fish" },
blowfish: { kind: "fish" }
}
I want to get string array types that might be this:
type FishInZoo = "guppy" | "blowfish"
type BirdInZoo = "flamingo" | "hawk" | "chicken"
So I'm thinking something like the following, but I don't know what the syntax would be:
type FishInZoo = keyof typeof zoo where { kind: "fish" }
Is this possible?