기본적으로 정의는 대문자로 시작한다.
interface Person {
name: string;
age: number;
}
type Person = {
name: string;
age: number;
}
interface Person {
name: string;
age: number;
}
interface Student extends Person {
school: string;
}
type Person = {
name: string;
age: number;
}
type Student = Person & {
school: string;
}
아래와 같이 Pick 을 통해서 필요한 타입만 사용 할 수 있다.
interface Todo {
title: string;
description: string;
completed: boolean;
}
type TodoPreview = Pick<Todo, "title" | "completed">;
const todo: TodoPreview = {
title: "Clean room",
completed: false,
};
[ref]
https://github.com/microsoft/TypeScript/wiki/Performance#preferring-interfaces-over-intersections
https://www.typescriptlang.org/docs/handbook/utility-types.html