Array `.at()` on readonly tuples
Author: SheraffCreated Mar 6, 2023Updated Apr 1, 2026
Labelsenhancementneeds-triage
Unless there is a good reason for typescript not to return the correct type when accessing a tuple with .at it feels like a good candidate for this library.
const a = [false, 1, '2'] as const
const b = a.at(0)
// ^? const b: false | 1 | "2" | undefined
const c = a.at(-1)
// ^? const c: false | 1 | "2" | undefinedBut with this library it could be:
const a = [false, 1, '2'] as const
const b = a.at(0)
// ^? const b: false
const c = a.at(-1)
// ^? const c: "2"Source: mattpocock/ts-reset