Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type CreditCard = {
number: string
expMonth: number
expYear: number
}
// Type with union operator
type Chargeable = { token: string } | { cvc: number }
type ChargeableCreditCard = CreditCard & Chargeable
/* ---------------------------------------
Interpreted type type will look like this:
type ChargeableCreditCard = (CreditCard & {
token: string;
}) | (CreditCard & {
cvc: number;
})
-----------------------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.