인터페이스 확장하기 - 인터페이스
/**
* **인터페이스의 확장 ( 상속 )**
*/
interface Animal{ // 이게 type 별칭이어도 확장 가능
name: string;
color: string;
}
interface Dog extends Animal{
// 상속 받는 인터페이스에서 동일한 프로퍼티의 타입을 다시 재정의 가능
// (하지만 원본 타입의 서브타입이어야만 됨)
isBark: boolean;
}
const dog : Dog = {
name : "",
color : "",
isBark : true,
}
interface Cat extends Animal{
isScratch: boolean;
}
interface Chicken extends Animal{
isFly: boolean;
}
**// 다중 확장**
interface DogCat extends Dog, Cat{}
const dogCat : DogCat = {
name : "",
color: "",
isBark : true,
isScratch : true
}