Looking for feedback, code that breaks it (check out the playground), ideas etc.
Show HN: Typical is TypeScript with type-safety at runtime
typical.elliots.dev
1–4 of 4 posts
Looking for feedback, code that breaks it (check out the playground), ideas etc.
Show HN: Typical is TypeScript with type-safety at runtime
typical.elliots.dev
This looks promising - I've always found the schema duplication annoying with Zod/Yup. Would be great to see benchmarks vs Typia/ArkType at https://moltar.github.io/typescript-runtime-type-benchmarks/
Running against the top 5 (+zod+yup) with node 24:
@sinclair/typebox-(ahead-of-time) - 176 M/ops/s
ts-runtime-checks - 176 M/ops/s
ts-auto-guard - 175 M/ops/s
typia - 173 M/ops/s
spectypes - 166 M/ops/s
typical - 150 M/ops/s
zod - 1.8 M/ops/s
yup - 0.2 M/ops/s
Top 5 and typical all generate pretty much the same code (a bunch of typeof checks). The only difference with typical is that it that the error throwing involves some string concatenation the others don't (typical logs the bad value, and can be used multiple places so passes in the property name).The benchmark itself is fine, but very simple. No arrays, only one level of nesting, no reuse of types, no template literals, no generic, no union types etc etc. Gives you a good idea of the general overhead, but isn't really playing to the strengths I think typical might have (hoisting functions that can be reused etc).
But speed is super important if you're intending to validate everywhere, so I'll keep my fork up to date. Thanks for the idea.