type-challenges / type-challenges

Collection of TypeScript type challenges with online judge

Home Page:https://tsch.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

11 - Tuple to Object

kukjun opened this issue · comments

type TupleToObject<T extends readonly PropertyKey[]> = {
  // Array, Tuble을 반복 가능한 구문으로 변경해야 함.
  // T[number]는 T의 모든 요소를 union으로 반환
  // 타입 매핑 구문으로 반복 진행
  [p in T[number]]: p
}