r/typescript • u/ssalbdivad • 19h ago
ArkType 3.0: TypeScript's smallest, fastest validator
ArkType 3.0 is out with @ark/aot, an optional build-time precompiler that compiles your type() definitions straight into standalone JS — no parser shipped, no new Function, and zero-build dynamic mode still works identically.
You write:
import { type } from "arktype"
const Shape = type({
kind: "'circle'",
radius: "number > 0"
}).or({
kind: "'square'",
side: "number > 0"
})
type Shape = typeof Shape.inferAnd @ark/aot emits plain JS checks like:
const isPositive = n => Number.isFinite(n) && n > 0
const checkShape = data => {
switch (data?.kind) {
case "circle": return isPositive(data.radius)
case "square": return isPositive(data.side)
}
return false
}Set algebra runs before codegen: unions auto-discriminate into a switch without declaring a discriminator, overlapping ranges collapse (> 0 & >= 10 -> >= 10), and contradictory intersections fail the build.
The 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) - 63x lighter startup on Node 24
Also in 3.0
- One-prompt migration:
npx skills add arktypeio/arktypefor moving from Zod or upgrading from 2.x, plusnpx arktype initandnpx arktype check - Bundlers & runtimes:
@ark/aot/unplugin(Vite, esbuild, Rolldown, Rollup, webpack, Rspack, Rsbuild, Bun, Farm),@ark/aot/turbopack(Next.js 16),@ark/aot/node,@ark/aot/bun, andtsc && ark emit— powered byoxc, nots-patch - Codecs, JSON Schema & i18n:
arktype/codecs(.encode), Standard Schema + auto-baked Standard JSON Schema, built-infromJsonSchema(compare/compose Zod schemas directly with.extends()/.overlaps()), andarktype/i18n - Cross-editor support: highlighting and inline errors in VS Code/Cursor/Windsurf, JetBrains IDEs, and Neovim (
arktype.nvim), plus Helix Tree-sitter highlighting (Zed in review) - Release post: https://arktype.io/docs/blog/3.0
- Precompile docs: https://arktype.io/docs/precompile
- Benchmarks: https://arktype.io/docs/precompile/benchmarks
- GitHub (MIT): https://github.com/arktypeio/arktype
Happy to answer any questions!
