Advent of TypeScript Play-Through! Days 1 - 13

Поділитися
Вставка
  • Опубліковано 28 лис 2024

КОМЕНТАРІ • 25

  • @mettle_x
    @mettle_x 11 місяців тому +7

    21:50 You can do it without an accumulator like this:
    type Reverse =
    T extends `${infer First}${infer Rest}` ?
    `${Reverse}${First}`
    : T;

  • @dimitrimitropoulos
    @dimitrimitropoulos 11 місяців тому +8

    ❤ 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!

  • @mettle_x
    @mettle_x 11 місяців тому +3

    14:51 You can exclude symbol from K like this: `good_${K extends Exclude ? K : never}`

  • @muzikant1986
    @muzikant1986 11 місяців тому +3

    13 day can be done with small amount of code
    type DayCounter = V extends Array<
    infer O
    >
    ? T extends U
    ? O
    : DayCounter
    : never;

  • @Tommy-ev6gv
    @Tommy-ev6gv 11 місяців тому +1

    5:19 love the Primagen reference.

  • @ChillAutos
    @ChillAutos 11 місяців тому +1

    This is brilliant. I’d love to watch you do more advent of code challenges in typescript.

  • @juanferrer5885
    @juanferrer5885 11 місяців тому

    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!

  • @ludatim7864
    @ludatim7864 11 місяців тому

    Wow, such a nice idea!

  • @helleye311
    @helleye311 11 місяців тому

    "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.

  • @metinsut
    @metinsut 11 місяців тому

    thanks

  • @kzinthant_
    @kzinthant_ 11 місяців тому +1

    I used Exclude for day 6

  • @obifortune
    @obifortune 11 місяців тому +1

    You can just do T["length"] to get the length of a tuple!

  • @marcush3997
    @marcush3997 11 місяців тому

    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

  • @obifortune
    @obifortune 11 місяців тому +2

    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;
    ```

  • @dinckelman
    @dinckelman 11 місяців тому +2

    You know you’ve succeeded as a dev, when you refer to your own blog posts for info hahaha

    • @ChillAutos
      @ChillAutos 11 місяців тому

      This was exactly what I thought to haha

  • @jaideepsingh8449
    @jaideepsingh8449 6 місяців тому

    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?

  • @lqueryvg
    @lqueryvg 11 місяців тому

    for day 10 you can write "string" instead of "infer _" - I think it makes more sense

  • @andrew1550
    @andrew1550 11 місяців тому

    Real vim pros map capslock to the escape key.

    • @andrew-burgess
      @andrew-burgess  11 місяців тому

      Yeah, that's good too. I map capslock to control.