Deviopath › TypeScript

Payroll with Interface extends

Medium · Interfaces

Employee extends Person, and Manager extends Employee with an extra bonus.

Write payrollByDepartment(staff: (Employee | Manager)[]): Record<string, number> that returns the total cost per department. A manager costs salary + bonus. Use the in operator ("bonus" in member) to narrow to Manager.

Next: Abstract Payment Methods