Last of Array
提出詳細
type Last<T extends ReadonlyArray<any>, U = null> = T extends [infer First, ...infer Rest] ? Last<Rest, First> : U
| 提出日時 | 2023-04-30 03:10:31 | 
|---|---|
| 問題 | Last of Array | 
| ユーザー | Dowanna | 
| ステータス | 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 }>>, ]