Guest User

Untitled

a guest
Jan 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. type Houses = {
  2. [HogwartsHouse.Gryffindor]: Gryffindor;
  3. [HogwartsHouse.Hufflepuff]: Hufflepuff;
  4. [HogwartsHouse.Ravenclaw]: Ravenclaw;
  5. [HogwartsHouse.Slytherin]: Slytherin;
  6. };
  7.  
  8. function isInHouse<T extends HogwartsHouse>(
  9. person: Person,
  10. house: T,
  11. ): person is Houses[T] {
  12. return isWizard(person) && person.house === house;
  13. }
  14.  
  15. function getPeopleLoyalTo(person: Person) {
  16. if (!isInHouse(person, HogwartsHouse.Gryffindor)) {
  17. return false;
  18. }
  19. return person.peopleLoyalTo;
  20. }
Add Comment
Please, Sign In to add comment