ArkType
The first isomorphic type system for TS/JS

Installation 📦
npm install arktype
If you're using TypeScript, you'll need at least 4.8
Note: Our APIs have largely stabilized at this point, but some may still change during the alpha/beta stages of our 1.0 release. If you have feedback that may require a breaking change, now is the time to let us know!
Your first type
Try it out.
import { type } from "../src/main.ts"
export const user = type({
name: "string",
device: {
platform: "'android'|'ios'",
"version?": "number"
}
})
export type User = typeof user.infer
export const { data, problems } = user({
name: "Alan Turing",
device: {
platform: "enigma"
}
})
if (problems) {
console.log(problems.summary)
}
Scopes
Try it out.
import { scope } from "../src/main.ts"
export const types = scope({
package: {
name: "string",
"dependencies?": "package[]",
"contributors?": "contributor[]"
},
contributor: {
email: "email",
"packages?": "package[]"
}
}).compile()
export type Package = typeof types.package.infer
const packageData: Package = {
name: "arktype",
dependencies: [{ name: "typescript" }],
contributors: [{ email: "david@sharktypeio" }]
}
packageData.dependencies![0].dependencies = [packageData]
export const { data, problems } = types.package(packageData)
API
ArkType supports many of TypeScript's built-in types and operators, as well as some new nes dedicated exclusively to runtime validation. In fact, we got a little ahead of ourselves and built a ton of cool features, but we're still working on getting caught up syntax and API docs. Keep an eye out for more in the next couple weeks! In the meantime, check out the examples from this README and use the type hints you get to learn how you can customize your types and scopes. If you have any questions, don't hesitate to reach out on the dedicated Discord channel!
Contributing
If you're interested in contributing to ArkType...
- Thank you! We'll do everything we can to make this as straightforward as possible, regardless of your level of experience.
- Check out our guide to get started!
License
This project is licensed under the terms of the
MIT license.