Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Houses = {
- [HogwartsHouse.Gryffindor]: Gryffindor;
- [HogwartsHouse.Hufflepuff]: Hufflepuff;
- [HogwartsHouse.Ravenclaw]: Ravenclaw;
- [HogwartsHouse.Slytherin]: Slytherin;
- };
- function isInHouse<T extends HogwartsHouse>(
- person: Person,
- house: T,
- ): person is Houses[T] {
- return isWizard(person) && person.house === house;
- }
- function getPeopleLoyalTo(person: Person) {
- if (!isInHouse(person, HogwartsHouse.Gryffindor)) {
- return false;
- }
- return person.peopleLoyalTo;
- }
Add Comment
Please, Sign In to add comment