Guest User

Untitled

a guest
Jan 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. type AAndB = {
  2. a: string;
  3. b: string;
  4. };
  5.  
  6. type Neither = {
  7. someOtherProp: string;
  8. };
  9.  
  10. type Props = AAndB | Neither;
  11.  
  12. // This will throw a typescript compiler warning, as a is present without b
  13. const example: Props = {
  14. a: 'something'
  15. }
  16.  
  17. // These will pass the typescript compiler
  18. const example2: Props = {
  19. a: 'something',
  20. b: 'something else',
  21. };
  22.  
  23. const example3: Props = {
  24. someOtherProp: 'some other prop',
  25. };
Add Comment
Please, Sign In to add comment