Type Challenges Judge

Reverse

提出詳細

type Reverse<T extends any[], Count extends any[] = []> = T extends [...infer Head, infer Last] ? Reverse<Head, [...Count, Last]> : Count
提出日時2024-10-30 02:06:40
問題Reverse
ユーザーbalckowl
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Reverse<[]>, []>>, Expect<Equal<Reverse<['a', 'b']>, ['b', 'a']>>, Expect<Equal<Reverse<['a', 'b', 'c']>, ['c', 'b', 'a']>>, ]