<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'];

객체의 속성 키는 문자열과 심볼만 가능하지 않나?

속성이 없는 인터페이스는 null과 undefined를 제외한 값을 대입할 수 있다.