<aside> 📌 인터페이스 선언을 통해 객체 타입에 이름을 붙이는 방법
</aside>
interface Person {
name: string;
age: number;
}
const person: Person = {
name: 'Lee',
age: 30
}
[NOTE] 그러나 배열을 정확하게 구현하기 위한 인터페이스는 다음 절에서 다룬다
interface AddFunc {
(x: number, y: number): number:
}
const addFunc: AddFunc = (x, y) => x + y;
interface Arr {
length: number;
[key: number]: string; // length를 제외한 모든 속성 키가 number
}
const arr: Arr = ['3', '2', '1'];
[key: number]
arr.slice
와 같은 배열의 메서드를 사용할 수 없음