Hacker News new | ask | show | jobs
by marcelr 205 days ago
oh i guess you use zod in every single part of your application? not just api level.

i was suggesting the result of zod parse is a type that shows how it’s been refined

however, .ipv4().parse(“..”) returns a type “string”

1 comments

there’s problem with branded types this way now that i think of it

string

type nonEmptyStr = string & NonEmpty

type ipv4Str = string & IPv4

it’s not obvious how you’d automatically determine ipv4Str is also a nonEmptyStr, since the types themselves are just labels, they don’t store the refinements at type level