TypeScript OOP에서 인터페이스 확장

TypeScript에서 인터페이스는 서로 상속받을 수 있습니다. 이러한 상호작용을 인터페이스의 확장이라고 합니다. 예제를 통해 살펴보겠습니다. ISize 인터페이스가 있다고 가정해 보겠습니다:

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

ISize를 확장하는 IStyle 인터페이스를 만들어 보겠습니다:

typescriptinterface IStyle extends ISize {
  color: string;
}

이제 IStyle 인터페이스를 구현하는 Figure 클래스를 생성해 보겠습니다. 우리 클래스는 인터페이스 자체의 속성과 그 부모의 속성을 모두 구현해야 합니다. 구현해 보겠습니다:

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

동작을 확인해 보겠습니다:

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

salary와 language 속성을 가진 IProgrammer 인터페이스를 생성하세요. 이 인터페이스가 name, birthday 속성을 가진 IUser를 상속하도록 하세요.

Задание 2

IProgrammer를 구현하는 Employee 클래스를 만드세요.