Last active
January 16, 2019 22:37
-
-
Save becca-bailey/4faff064b612712b2827cc79c0fb0e94 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 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