Extending Interfaces in OOP in TypeScript

Interfaces in TypeScript can inherit from each other. This interaction is called extending interfaces. Let's look at an example. Let's say we have an interface ISize:

typescriptinterface ISize {
  height: number;
  width: number;
}

Let's create an interface IStyle that will extend ISize:

typescriptinterface IStyle extends ISize {
  color: string;
}

Now let's create a class Figure that implements the interface IStyle. Our class will need to implement both the interface's property and its parent's. Let's do this:

typescriptclass Figure implements IStyle {
  height: number;
  width: number;
  color: string;
  
  constructor(height: number, width: number, color: string) {
    this.height = height;
    this.width  = width;
    this.color  = color;
  }
}

Let's check the work:

typescriptlet fig = new Figure(130, 200, 'green');
console.log(fig);
Задание 1

Create an interface IProgrammer with properties salary and language. Let this interface inherit IUser with properties name, birthday.

Задание 2

Make a class Employee that implements IProgrammer.