Look me in the eyes and tell me this code isn't beautiful.
Arrays are like standard JavaScript arrays. a bag of elements that can grow or shrink.
Tuples, on the other hand, are fixed in length and type. They know exactly how many elements they contain and the specific types of elements at each position.
In #TypeScript, Arrays and Tuples are not the same, So how do we differentiate between the two at the type level? The following type does exactly that using a clever trick (explained in the replies):
By the way, hereβs the usual way to get the last element of a tuple:
Hereβs whatβs happening in this code: weβve created a tuple thatβs one element longer than the original T. Now, the length of the original tuple (T["length"] == 4) becomes our index, pointing to the last element of the newly created tuple.
I stumbled upon this piece of #TypeScript art, a type helper that cleverly gets the last element of any tuple type. (explanation in the replies)
I've completed πππ Thank You! - Advent of TypeScript 2024 adventofts.com/events/2024/25
tsup
I've completed π©Bernard's New Demands 2: Electric Boogaloo - Advent of TypeScript 2024 adventofts.com/events/2024/21
I imagine you saying the same thing about bsky
I've completed Day 18 - Advent of TypeScript 2024 adventofts.com/events/2024/18
Yeah, todayβs challenge is much easier. 16 was tough, and the incorrect tests made it worse, I spent almost three hours trying to make it work.
even with the help of all LLM's I'm not able to pass test 4
15 was hard, tbh. I got to the final solution through brute force only.
Advent of Typescript 2024: Day 15 Solution
I've completed Day 15 - Advent of Typescript 2024 adventofts.com/events/2024/15
Advent of Typescript: Day 14
I've completed π©Bernard's Long List Of Names - Advent of TypeScript 2024 adventofts.com/events/2024/12
The astro schema package is reaching a nice milestone, so I thought Iβd share it with you, go
@astro.build π
I've completed π Santa Refuses To Use Threads - Advent of TypeScript 2024 adventofts.com/events/2024/6
React v19 is now stable!
react.dev/blog/2024/12...
React 18 is a thing of the past, hail the new king, React 19!
features iβm excited about in react 19
I've completed Drafting This Year's Routes - Advent of TypeScript 2024 adventofts.com/events/2024/5
Astro 5.0 is here.
Content layer, server islands, simplified prerendering, type-safe env, @vite.dev v6. All stable.
Go see what you can do π
astro.build/blog/astro-5/
Ready for @astro.build v5 ππͺ
astro-svg-loaders@5.0.0
astro-seo-schema@5.0.0
astro-useragent@5.0.0
astro-purgecss@5.0.0
astro-seo-meta@5.0.0
I've completed β‘Blitzen Fixes The Mess #AdventOfTypescript adventofts.com/events/2024/2
I've completed The Reindeer Have Had Enough - Advent of TypeScript 2024 adventofts.com/events/2024/1
With the release of php8.4, iβm excited to share a tool iβve been working on, which I think is the easiest way to set up the latest version of php on any apt-based linux system!
π give it a try: tryphp.dev
#php #linux #devtools