Type Challenges Judge

Reverse

提出詳細

type Reverse<T extends unknown[], O extends unknown[] = []> = T extends [infer L, ...infer R] ? R extends unknown[] ? Reverse<R, [L, ...O]> : [L, ...O] : O
提出日時2023-08-08 08:21:41
問題Reverse
ユーザーookkoouu
ステータス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']>>, ]