Skip to content

Instantly share code, notes, and snippets.

@koss-lebedev
Last active April 28, 2019 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koss-lebedev/58bd0708a8c99e870dc9e05f795960db to your computer and use it in GitHub Desktop.
Save koss-lebedev/58bd0708a8c99e870dc9e05f795960db to your computer and use it in GitHub Desktop.
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