오늘의 한마디
type alias와 같이 타입을 지정하는 interface에 대해 알아보고
또, 어떠한 점이 다른지 알아보자.
interface Person {
name : string,
age : number,
}
// extends
interface Child extends Person {
disc : string
}
interface와 type의 다른점은
바로 자바스크립트의 class처럼 extends가 가능
또 interface는 중복이 가능하다. 똑같은 이름의 인터페이스를 만들수 있다. 중복선언을 하면 자동으로 extends가 된다.
더 알아보기 )
type에서 속성합치기
type Person = { name : string }
type Child = { age : number } & Person
&기호를 사용하여 합치는 것을 intersection이라고 한다.