Your First Type
If you already know TypeScript, congratulations- you just learned most of ArkType's syntax 🎉
Define
If you make a mistake, don't worry- every definition gets the autocomplete and validation you're used to from your editor, all within TypeScript's type system.
Will ArkType crash my TypeScript server?
Thousands of hours of optimization have gone into making validating native type syntax not just feasible, but often much faster than alternatives âš¡
Compose
Suppose we want to move platform
and version
from our original type to a new device
property.
To decouple device
from user
, just move it to its own type and reference it.
Validate
At runtime, we can pass unknown
data to our type and get back either a validated User
or an array of clear, customizable errors with a root summary
.
And that's it! You now know how to to define a Type
use it to check your data at runtime.
Next, we'll take a look at how ArkType extends TypeScript's type system to handle runtime constraints like maxLength
and pattern
.