shaKY-iota / type-challenges

Collection of TypeScript type challenges with online judge
https://tsch.js.org/
MIT License
0 stars 0 forks source link

3188 - Tuple to Nested Object #38

Open shaKY-iota opened 2 years ago

shaKY-iota commented 2 years ago
// your answers
type TupleToNestedObject<T extends string[], U> = T extends [string, ...infer Rest] ? Rest extends string[] ? { [P in T[0]]: TupleToNestedObject<Rest, U> } : never : U;