Estendendo interfaces em POO em TypeScript

Interfaces em TypeScript podem herdar umas das outras. Essa interação é chamada de extensão de interfaces. Vamos ver um exemplo. Suponha que temos uma interface ISize:

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

Vamos criar uma interface IStyle que estende ISize:

typescriptinterface IStyle extends ISize {
  color: string;
}

Agora vamos criar uma classe Figure que implementa a interface IStyle. Nossa classe precisará implementar tanto a propriedade da própria interface quanto a de seu pai. Vamos fazer isso:

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;
  }
}

Vamos verificar o funcionamento:

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

Crie uma interface IProgrammer com as propriedades salary e language. Deixe esta interface herdar de IUser com as propriedades name, birthday.

Задание 2

Faça uma classe Employee que implemente IProgrammer.