bh2980.dev

3060 - Unshift

  • #Type Challenges
  • #TypeScript

질문

Array.unshift의 타입 버전을 구현하세요.

예시:

type Result = Unshift<[1, 2], 0> // [0, 1, 2]

/* _____________ 테스트 케이스 _____________ */
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Unshift<[], 1>, [1]>>, Expect<Equal<Unshift<[1, 2], 0>, [0, 1, 2]>>, Expect<Equal<Unshift<['1', 2, '3'], boolean>, [boolean, '1', 2, '3']>>, ]

풀이