interfaces.ts 810 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { Category } from "./enums";
  2. interface DamageLogger {
  3. (reason: string): void;
  4. }
  5. interface Book {
  6. author: string,
  7. available: boolean,
  8. category: Category;
  9. id: number,
  10. pages?: number,
  11. title: string,
  12. markDamaged?: DamageLogger,
  13. }
  14. interface Person {
  15. name: string;
  16. email: string;
  17. }
  18. interface Author extends Person {
  19. numBooksPublished: number;
  20. }
  21. interface Librarian extends Person {
  22. department: string,
  23. assistCustomer: (custName: string) => void,
  24. }
  25. interface Inventory<T> {
  26. getNewestItem: () => T;
  27. addItem: (newItem: T) => void;
  28. getAllItems: () => Array<T>;
  29. }
  30. // let bookInventory: Inventory<Book>;
  31. // (snip...populate bookInventory)
  32. // let allBooks: Books = bookInventory.getAllItems();
  33. export {
  34. Author,
  35. Book,
  36. DamageLogger as Logger,
  37. Inventory,
  38. Librarian,
  39. }