Docs

ExtractArrayElement

type ExtractArrayElement<TArray extends any[]> = TArray extends [
  infer TElement,
  ...infer TRest,
]
  ? TRest extends []
    ? TElement
    : TArray
  : never;