News for hackers. Stuff that matters.
Re:Functions and algorithms implemented purely with TypeScri... by ncallaway on Wednesday July 05, 2023 @10:30AM (#36600972)
If you’re taking in data from an external source that needs to be validated, I highly recommend a schema library like zod, that can produce a typescript type.

That way you can define the type in a single place, have runtime validation for that type, but also be able to use the type in typescript at compile time.

Re:Functions and algorithms implemented purely with TypeScri... by sk0g on Wednesday July 05, 2023 @08:02PM (#36609035)
Can you use something like Zod with the newtype pattern? I use DDD-style types for domain specific data over primitives.