Namchee
namchee.dev
Namchee
@namchee.dev
Day 21. We can (again) extend the previous day functionality.

We can check if an element exist in an array using `extends`
December 21, 2024 at 1:20 PM
Day 20. We can re-use the parser code from the previous day. But we do need to implement the result object logic.
December 20, 2024 at 9:27 AM
Day 19. The trick here is to parse the line one-by-one and trimming them.
December 19, 2024 at 11:36 AM
TIL: GitHub has 👍 in issues now.
December 18, 2024 at 2:59 PM
Day 18. We are dealing with unprovided generics.

The trick is to assert whether the generic is provided or not. If it's not provided, access the array element. Otherwise, return the generic as-is.
December 18, 2024 at 2:03 PM
Day 17. We can strongly-type the composition and utilities using generics.

To avoid type narrowing for string utilities, we can recast it using string utility types.
December 17, 2024 at 11:59 AM
Day 16. We can deal with recursion with the help of `ReturnType`
December 17, 2024 at 11:58 AM
Day 15. We are dealing with string inference combined with recursions.

Since I don't want to deal with some funny cases, I just implemented hacky helper functions to deal with it (don't do this 😂)
December 15, 2024 at 7:08 AM
Day 14. We are introduced with AsyncGenerator type which is a signature for generator functions.

To get the return type, we can `infer` it.
December 14, 2024 at 10:43 AM
Day 13, this one is a bit difficult as we need to understand covariant and contravariant of TypeScript.

To enforce an invariant, we need to apply `out` to enforce contravariance and `in` to enfore covariance to the generic type.
December 13, 2024 at 2:48 PM
Day 12, a few hints:

1. Array is an object, so you can iterate it as you would iterate mapped types, which doesn't have stack overflow issues
2. The elements are a tuple, so you can quickly access the members by their indexes.
3. You can extract the numerical value by infering the numeric string.
December 12, 2024 at 12:52 PM
Day 11. To make a type `newable`, we can define a `new` contract for it.

The key extraction is a bit hacky though!
December 11, 2024 at 12:45 PM
Day 10. Was very surprised that type accepts bitwise operators.
December 10, 2024 at 11:27 AM
Day 9. Another practical day: defining types for untyped Node modules.

No, you don't need to export the types.
December 9, 2024 at 6:26 AM
Day 8. We're going a bit practical here: extending the `process.env` of NodeJS
December 8, 2024 at 5:40 AM
Day 7, we can narrow the types by spreading the type array.
December 7, 2024 at 5:43 AM
Day 6, we need to narrow the type a bit using `extends`
December 6, 2024 at 1:53 PM
Day 5, we are introduced with the concept of generics that can be used here to directly pass the value as type.
December 5, 2024 at 5:42 AM
Day 4, not so different from from Day 3: ignore the pre-defined type and directly change the type.
December 5, 2024 at 12:39 AM
Day 3 is an introduction to `keyof`. A bit confusing if you don't know what the problem actually wants.

You can actually erase the type here.
December 3, 2024 at 11:54 AM
Day 2 is very similar to Day 1, we just need to swap the values
December 2, 2024 at 12:17 PM
Day 1 is pretty simple, as usual. We just need to swap the types
December 1, 2024 at 5:18 AM