Skip to content

Instantly share code, notes, and snippets.

@twavv
Created June 16, 2019 06:01
Show Gist options
  • Save twavv/34a1c3da3b986cf646a721222cf76809 to your computer and use it in GitHub Desktop.
Save twavv/34a1c3da3b986cf646a721222cf76809 to your computer and use it in GitHub Desktop.
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