Guest User

Untitled

a guest
Feb 7th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // working with pipes and type
  2. type Fruit = "orange" | "banana" | "strawberry";
  3.  
  4. // working with types and functions
  5. type EatFruitFunction = (fruit: Fruit) => void;
  6.  
  7. // typing objects using type
  8. type User = {
  9. username: string,
  10. email: string,
  11. password: string,
  12. }
  13.  
  14. type UserList = {
  15. users: User[]
  16. }
  17.  
  18. // Composing `n` types
  19. type Composed = User & UserList & {
  20. // Here you can write your other props
  21. example: Object
  22. };
  23.  
  24. /**
  25. How this will look like on the end:
  26.  
  27. {
  28. example: {},
  29. username: 'foo',
  30. email: 'foo@foo.com',
  31. password: '123',
  32. users: [...],
  33. }
  34. */
Add Comment
Please, Sign In to add comment