Last active
April 28, 2019 13:50
-
-
Save koss-lebedev/58bd0708a8c99e870dc9e05f795960db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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