namchee.dev
39 posts
17 followers
98 following
Regular Contributor
Active Commenter
comment in response to
post
Is this documented somewhere?
comment in response to
post
And now, we can format without having to focus too much on the tools that we use.
I hate when people starts to `pls migrate to Y, X sucks now!` every time these kind of tools comes out.
They're forgetting the main purpose of these tools: make your code great
comment in response to
post
Lately, we also have eslint-react (www.npmjs.com/package/@esl...), which applies ESLint rules for your React-based projects without being too binded to `react-dom`
comment in response to
post
First, we have Anthony Fu's ni (github.com/antfu-collec...), which makes you ignore package manager wars.
comment in response to
post
You can use ranges too! VitePress has integrated a lot of Shiki transformers internally.
vitepress.dev/guide/markdo...
comment in response to
post
Day 21. We can (again) extend the previous day functionality.
We can check if an element exist in an array using `extends`
comment in response to
post
Day 20. We can re-use the parser code from the previous day. But we do need to implement the result object logic.
comment in response to
post
Day 19. The trick here is to parse the line one-by-one and trimming them.
comment in response to
post
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.
comment in response to
post
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.
comment in response to
post
Day 16. We can deal with recursion with the help of `ReturnType`
comment in response to
post
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 π)
comment in response to
post
Day 14. We are introduced with AsyncGenerator type which is a signature for generator functions.
To get the return type, we can `infer` it.
comment in response to
post
A successor of github.com/nvbn/thefuck?
comment in response to
post
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.
comment in response to
post
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.
comment in response to
post
Day 11. To make a type `newable`, we can define a `new` contract for it.
The key extraction is a bit hacky though!
comment in response to
post
frameworks will add it as a default once itβs out of beta, see roadmap here react.dev/blog/2024/10...
comment in response to
post
Day 10. Was very surprised that type accepts bitwise operators.
comment in response to
post
Day 9. Another practical day: defining types for untyped Node modules.
No, you don't need to export the types.
comment in response to
post
Day 8. We're going a bit practical here: extending the `process.env` of NodeJS
comment in response to
post
Day 7, we can narrow the types by spreading the type array.
comment in response to
post
Day 6, we need to narrow the type a bit using `extends`
comment in response to
post
Day 5, we are introduced with the concept of generics that can be used here to directly pass the value as type.
comment in response to
post
It seems that I'm too obsessed in keeping the pre-defined data type intact π
comment in response to
post
Day 4, not so different from from Day 3: ignore the pre-defined type and directly change the type.
comment in response to
post
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.
comment in response to
post
Every day, I wonder why do we need 2 module formats for JavaScript to suffer...
comment in response to
post
Day 2 is very similar to Day 1, we just need to swap the values
comment in response to
post
Day 1 is pretty simple, as usual. We just need to swap the types