Imagine you have an interface called X
:
type X = {
red: number,
blue: string
}
Can a union type Y
be created using mapped types? If not, are there other ways to construct it at the type level?
type Y = {
kind: "red"
payload: number
} | {
kind: "blue"
payload: string
}