Cheat Sheet
A quick reference for ArkType's most common patterns. For full docs, explore the sidebar.
Syntax Kinds
ArkType offers three ways to define the same type. Use whichever fits your context.
Keywords
Keywords follow a typescriptType.constraint.subconstraint pattern:
Operators
Objects
Arrays and Tuples
Composition
Morphs and Pipes
Type Inference
Error Handling
Common Gotchas
| Mistake | Fix |
|---|---|
name: "string | undefined" for optional | Use "name?": "string" — append ? to the key |
type([Schema]) for arrays | Use Schema.array() — brackets create tuples |
"Record<string, T>" with T a variable | Use type.Record("string", T) or { "[string]": T } |
Manually re-validating after type() | Trust ArkType's output — it already validated the structure |
type User = typeof Schema.t | Use typeof Schema.infer for the output type |