알고리즘/Type Challenges
3060 - Unshift
제주도랏맨
2023. 9. 17. 03:47
출처: Type Challenges, https://github.com/type-challenges/type-challenges/blob/main/README.ko.md
3060 - Unshift
`Array.unshift`의 타입 버전을 구현하세요.
type Result = Unshift<[1, 2], 0> // [0, 1, 2,]
풀이
type Unshift<T, U> = T extends [...infer Rest] ? [U, ...Rest] : never