- interface
- 구조 선언에 최적
- 클래스 친화적
- 선언 병합
- 활용
- 객체, 클래스 구조 명세
-
interface Animal { name: string } interface Dog extends Animal { breed: string }
-
- api 정의
- 객체, 클래스 구조 명세
- type
- 타입 조작에 최적
- 유니온 / 제네릭 / 고급 타입 친화적
- 단일 선언
- 활용
- 유니온
-
type Shape = { kind: 'circle'; r: number } | { kind: 'square'; size: number }
-
- 함수 반환, 유틸리티 타입
-
type Keys = 'a' | 'b' type Obj = { [K in Keys]: number }
-
- 유니온