Created
June 16, 2019 06:01
-
-
Save twavv/34a1c3da3b986cf646a721222cf76809 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
interface Address { | |
lineOne: string; | |
lineTwo: string | undefined; | |
city: string; | |
} | |
type AddressWithOptionalProperties = UndefinedOptional<Address>; | |
const address: Address = { | |
lineOne: "1234 Main St.", | |
// lineTwo is required in this interface | |
lineTwo: undefined, | |
city: "Springfield", | |
}; | |
const addressOptional: AddressWithOptionalProperties = { | |
lineOne: "1234 Main St.", | |
// lineTwo not required! | |
city: "Springfield", | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment