I have a dilemma:
type TypeLetter = "TypeA" | "TypeB"
type TypeNumber = "Type1" | "Type2"
I am trying to restrict the combinations of values from these types. Only "TypeA" and "Type1" can be paired together, and only "TypeB" and "Type2" can be paired together.
How can I define a type called Restricted
to enforce these restrictions? In other words, where these combinations are allowed:
const valid1: Restricted = {
valLetter: "TypeA"
valNumber: "Type1"
}
const valid2: Restricted = {
valLetter: "TypeB"
valNumber: "Type2"
}
But this combination is not allowed:
const nope: Restricted = {
valLetter: "TypeB"
valNumber: "Type1"
}