Type Challenges Judge

Last of Array

提出詳細

type Last<T extends any[]> = T extends [infer L, ...infer R] ? R["length"] extends 0 ? L : Last<[...R]> : never
提出日時2023-08-07 17:17:19
問題Last of Array
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Last<[3, 2, 1]>, 1>>, Expect<Equal<Last<[() => 123, { a: string }]>, { a: string }>>, ]