Skip to content

Instantly share code, notes, and snippets.

@becca-bailey
Last active January 16, 2019 22:37
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save becca-bailey/4faff064b612712b2827cc79c0fb0e94 to your computer and use it in GitHub Desktop.
Save becca-bailey/4faff064b612712b2827cc79c0fb0e94 to your computer and use it in GitHub Desktop.
type AAndB = {
a: string;
b: string;
};
type Neither = {
someOtherProp: string;
};
type Props = AAndB | Neither;
// This will throw a typescript compiler warning, as a is present without b
const example: Props = {
a: 'something'
}
// These will pass the typescript compiler
const example2: Props = {
a: 'something',
b: 'something else',
};
const example3: Props = {
someOtherProp: 'some other prop',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment