CHALLENGE 2: Extend an Interface ================================= SOLUTION: interface Person { name: string; age: number; } interface Employee extends Person { employeeId: number; department: string; } // Create an employee const employee: Employee = { name: "Alice", age: 30, employeeId: 12345, department: "Engineering" }; // All of Person's properties are required too: const anotherEmployee: Employee = { name: "Bob", age: 28, employeeId: 12346, department: "Sales" }; EXPLANATION: - "interface Person { ... }" — base interface with name and age - "interface Employee extends Person { ... }" — Employee inherits from Person - Employee MUST have: name (from Person), age (from Person), employeeId, department - The "extends" keyword means Employee is a specialized version of Person WHY USE INTERFACE INHERITANCE: - DRY principle: don't repeat name and age in Employee - Clarity: Employee IS a Person (plus more) - Consistency: all employees have the base Person properties - Easy to add shared properties: add to Person once, all children get it ALTERNATIVE APPROACH (if you wanted multiple interfaces): interface HasName { name: string; } interface HasAge { age: number; } interface Person extends HasName, HasAge {} interface Employee extends Person { employeeId: number; department: string; } TESTING: ✅ Works: { name: "Charlie", age: 35, employeeId: 123, department: "HR" } ❌ Error: { name: "Charlie", employeeId: 123, department: "HR" } (missing age from Person) ❌ Error: { name: "Charlie", age: 35, department: "HR" } (missing employeeId)