Advent of TypeScript Play-Through! Days 1 - 13
HTML-код
- Опубликовано: 15 дек 2023
- Chapters
- Day 1 - 0:46
- Day 2 - 1:50
- Day 3 - 2:40
- Day 4 - 3:34
- Day 5 - 5:00
- Day 6 - 7:18
- Day 7 - 11:01
- Day 8 - 14:58
- Day 9 - 17:19
- Day 10 - 21:52
- Day 11 - 23:30
- Day 12 - 28:16
- Day 13 - 33:29
- Conclusion - 46:52
Advent of TypeScript: typehero.dev/aot-2023
Distributive Conditional Types: shaky.sh/ts-distributive-cond...
Thanks to @MichiganTypeScript for all the challenges in this video!
My Links
shaky.sh
shaky.sh/tools
/ andrew8088
mastodon.social/@andrew8088
#programming #coding #typescript #javascript #adventofcode
#frontenddeveloper #backenddeveloper #softwareengineer #softwareengineering #softwaredevelopment - Наука
❤ hope everyone enjoys them! It was super fun writing the prompts but I got to say: there are many many other people involved with making typehero into what it has become in such a short span of time!
21:50 You can do it without an accumulator like this:
type Reverse =
T extends `${infer First}${infer Rest}` ?
`${Reverse}${First}`
: T;
13 day can be done with small amount of code
type DayCounter = V extends Array<
infer O
>
? T extends U
? O
: DayCounter
: never;
5:19 love the Primagen reference.
lol, I totally missed that!
14:51 You can exclude symbol from K like this: `good_${K extends Exclude ? K : never}`
This is brilliant. I’d love to watch you do more advent of code challenges in typescript.
I couldn't enjoy more this type of code challenge videos! I would love to see more of this. Maybe not just type only. great video!
"Type instantiation is excessively deep" is my worst enemy when doing fun typescript stuff.
I've often mapped types to other types recursively, and since the initial type can be nested objects I do technically need to recurse infinitely, but in practice with concrete types that nest 2-3 layers deep it should still work. I wish TS didn't consider the generic when doing the recursion depth check, just concrete types that come out.
Wow, such a nice idea!
thanks
I used Exclude for day 6
You can just do T["length"] to get the length of a tuple!
You know you’ve succeeded as a dev, when you refer to your own blog posts for info hahaha
This was exactly what I thought to haha
i was able to get away with something really short for the day13(still has recursion lol)
```ts
type DayCounter<
F extends number,
L extends number,
R extends readonly number[] = [1],
> = R["length"] extends L
? R[number] | L
: DayCounter;
```
Hey buddy, i saw your advent of typescript series, i am beginer, I got stuck in one of the similar code which uses advent of typescript logics, could you please help me out?
for day 10 you can write "string" instead of "infer _" - I think it makes more sense
type IsObject = P extends Function? never : P extends object? P: never;
type SantaListProtector = {
readonly [K in keyof T]: T[K] extends IsObject? SantaListProtector: T[K]
};
a spin on the explicit solution but not sure if there's hidden issue with this
Real vim pros map capslock to the escape key.
Yeah, that's good too. I map capslock to control.