로 객체 형태를 설명하는 또 다른 방법입니다. 인터페이스는 별칭으로 된 객체 타입과 여러 면
에서 유사하지만 일반적으로 더 읽기 쉬운 오류 메시지, 더 빠른 컴파일러 성능, 클래스와의 더
나은 상호 운용성을 위해 선호됩니다.
7.1
타입 별칭 타입 별칭
vsvs
. 인터페이스. 인터페이스
다음은
born
:
number
와
name
:
string
을 가진 객체를 타입 별칭으로 구현하는 간략한 구문
입니다.
type Poet = {
born: number;
name: string;
};
132
2
부
특징
다음은 인터페이스로 구현한 동일한 구문입니다.
interface Poet {
born: number;
name: string;
}
두 구문은 거의 같습니다.
세미콜론(
;
)을 선호하는 타입스크립트 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.