📢 이 문서는 다른 블로그의 글을 축약하여 작성된 문서입니다.
참고 및 출처 : Type vs Interface, 언제 어떻게? - 남현욱
🔔 결론: 자신이 없다면 interface 를 사용하자
type
키워드를 사용type
을 중복선언하면 확장되지 않는다.extends
키워드로 확장할 순 있다.interface
를 중복선언하면 확장된다.//선언병합의 예시코드
interface Pencil {
name: string;
color: string;
price: number;
}
interface Pencil {
isDiscount: boolean;
}
// 같은 이름의 인터페이스를 선언하여서 아래처럼 선언병합됨
interface Pencil {
name: string;
color: string;
price: number;
isDiscount: boolean;
}