3 ms·
Honestly any typescript library with great type safety probably has seriously gnarly generics inside. Here[1] is a random file from kysely, which is surprisingl
by chamomeal 2y ago
Honestly any typescript library with great type safety probably has seriously gnarly generics inside. Here[1] is a random file from kysely, which is surprisingly readable even though kysely's type safety is incredibly good.
But things I encounter in the regular non-library world are usually recursive types that have specific constraints. A couple years ago I had my first foray into typescript generics, and was so stumped that I actually gave up. I was trying to map the type of one nested object to another. This[2] is the stackoverflow post from the legendary jcalz that saved me! Check jcalz's link to the TS playground
[1]https://github.com/kysely-org/kysely/blob/master/src/query-builder/output-interface.ts https://github.com/kysely-org/kysely/blob/master/src/query-b...
[2]https://stackoverflow.com/questions/72461962/is-it-possible-to-recursively-map-one-json-like-type-to-another-in-typescript https://stackoverflow.com/questions/72461962/is-it-possible-...