DEV Community

Discussion on: Typescript Series - First and Last of Array Type

Collapse
 
tylim88 profile image
Acid Coder • Edited

there is an easier way to get the first type

type a = [1,2,3,4]

type b = a['0'] // 1
type c = a[0] // 1
Enter fullscreen mode Exit fullscreen mode

playground

does not work on empty tuple though

Collapse
 
sarmunbustillo profile image
Sarmun Bustillo

That's exactly right! that is the other approach