3 ms·
This was driving me nuts in a project with lots of backend churn. Runtime type validation libraries like typebox and zod (I like typebox) can really save your b
by DangitBobby 3y ago
This was driving me nuts in a project with lots of backend churn. Runtime type validation libraries like typebox and zod (I like typebox) can really save your bacon.
The downside is the underlying types tend to be more complex when viewed in your IDE, but I think it's worth it.
- eyelidlessness 3y agoHere’s a neat trick for those complex types: type Identity<T> = T // This can be made recursive to an extent, alas I’m on mobile type Merge<T> = { [K in keyof T]: Identity<T[K]> } type ReadableFoo = Merge<UnreadableFoo>