[TS] 인덱스드 액세스 타입
TIL
인덱스드 액세스 타입(Indexed Access Type)은 객체, 배열, 튜플 타입으로부터 특정 프로퍼티나 요소의 타입만 추출하는 타입이다.객체 프로퍼티 타입 추출게시글 작성자 정보를 출력하는 함수를 작성해보자.interface Post { title: string; content: string; author: { id: number; name: string; };}function printAuthorInfo(author: { id: number; name: string }) { console.log(`${author.name}-${author.id}`);} 만약 Post의 author 타입이 수정되면 함수의 매개변수 타입도 함께 수정해야 한다.인덱스드 액세스 타입을 사용하면 이 문..