Razširjanje vmesnikov v OOP v TypeScript

Vmesniki v TypeScript lahko dedujejo drug od drugega. Takšno interakcijo imenujemo razširjanje vmesnikov. Poglejmo si na primeru. Recimo, da imamo vmesnik ISize:

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

Naredimo vmesnik IStyle, ki bo razširjal ISize:

typescriptinterface IStyle extends ISize {
  color: string;
}

Zdaj naredimo razred Figure, ki implementira vmesnik IStyle. Naš razred bo moral implementirati tako lastnost samega vmesnika, kot tudi njegovega starša. Naredimo to:

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

Preverimo delovanje:

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

Ustvarite vmesnik IProgrammer z lastnostmi salary in language. Naj ta vmesnik deduje IUser z lastnostmi name, birthday.

Задание 2

Naredite razred Employee, ki implementira IProgrammer.