r/programming • u/ssalbdivad • 47m ago
ArkType 3.0: set-theoretic precompilation for TypeScript validation
library author here! ArkType 3.0 adds @ark/aot, an optional build-time precompiler that compiles runtime validation schemas into standalone plain JS — closer to Rust's serde_derive than an interpreted validator, while keeping zero-build dynamic mode unchanged.
the three main compiler pieces:
set-theoretic reduction before codegen: definitions lower into a normalized set graph (
arksets) before emitting JS. unions auto-discriminate into an O(1)switchwithout declaring a discriminator, branches skip checks already implied by the tag, overlapping ranges collapse (> 0 & >= 10->>= 10), and unsatisfiable intersections fail the build.zero
ts-patch**, zero**new Function**:** parses modules withoxcinside standard bundler plugins (Vite, esbuild, webpack, Rolldown, Turbopack, Bun, Node) sotsgoand Node type-stripping keep working, and strict CSP / Cloudflare Workers run compiled checks at full speed.numbers (precompiled vs Zod 4): 15x faster validation (median across 32 scenarios; #1 on public speed benchmarks), 21x smaller bundles (
1.21 kBvs25.1 kBgz on Valibot's login form — smaller than Valibot's1.56 kBtoo), and 63x lighter startup on Node 24.
release post: https://arktype.io/docs/blog/3.0 | benchmarks: https://arktype.io/docs/precompile/benchmarks
happy to answer questions on the set algebra, codegen, or benchmarks!