Last of Array with Aaron Harper - TypeScript Type Challenges #15 [MEDIUM]

preview_player
Показать описание
Accessing the values of an array is an essential skill. This one seems a little tricky at first, but before long the solution should become more clear. It seems pedantic, but it's going to come up again: trust me.

00:00 description of the challenge
00:19 attempt at a solution
01:17 all tests pass
01:20 alternatives

Рекомендации по теме
Комментарии
Автор

Aaron Harper is a software engineer at Inngest, building an SDK-driven platform that simplifies event-driven architecture. TypeScript and Go are his languages of choice, but he's cool with anything that lets him stay far away from object-oriented programming. He loves programming, gardening, and spending time outside with his growing family.

MichiganTypeScript
Автор

"well uhh i wouldn't have had the typo" - burned!

FunctionGermany
Автор

I dont even work with TS, but watching this videos is teaching me so many things, the solution changing the size of the array is crazy smart

lucasmartins
Автор

damn that one with the array extension to use T["length"] is super creative =O

FunctionGermany
Автор

indeed interesting alternative solution!

justsample
Автор

Where Last1 dude learn this kind of things??? That was crazy!

felipegutierrez
Автор

type Last<T extends unknown[]> = T extends [infer Head, ...infer Tail] ? Tail extends [] ? Head : Last<Tail> : never

harunskender