인덱스드 엑세스 타입 - 타입 조작하기

/**
 * 인덱스드 엑세스 타입
 */

type PostList = {
    title: string;
    content: string;
    author:{
        id: number;
        name: string;
        age: number;
        // location: string;
    }
}[];

function printAuthorInfo (author: PostList[number]['author']){  // Post['author']['id'] 이런식으로 중첩으로 가져올 수 있다.
    console.log(`${author.name}-${author.id}`)
}

const post : PostList[number] = { // number나 숫자 넣으면 배열타입의 요소를 추출함
    title: "게시글 제목",
    content: "게시글 본문",
    author: {
        id: 1,
        name: "박정수",
        age: 26,
    }
}

printAuthorInfo(post.author)

type Tup = [number, string, boolean];

type Tup0 = Tup[0]
type Tup1 = Tup[1]
type Tup2 = Tup[2]
// type Tup3 = Tup[3]
type TupNum = Tup[number] // 이거는 3타입의 최적의 공동 타입을 뽑음