arktype
2.2.9 · 20 Oct 2026MIT3.4M / weekRepositoryHomepagenpmAtom feed
2.2.9 is the newest release of 2.x.
Release note
The section about arktype of a note shared by several packages.
exactOptionalPropertyTypes
By default, ArkType validates optional keys as if TypeScript's exactOptionalPropertyTypes is set to true.
const MyObj = type({
"key?": "number"
})
// valid data
const validResult = MyObj({})
// Error: key must be a number (was undefined)
const errorResult = MyObj({ key: undefined })This approach allows the most granular control over optionality, as | undefined can be added to properties that should accept it.
However, if you have not enabled TypeScript's exactOptionalPropertyTypes setting, you may globally configure ArkType's exactOptionalPropertyTypes to false to match TypeScript's behavior. If you do this, we'd recommend making a plan to enable exactOptionalPropertyTypes in the future.
import { configure } from "arktype/config"
// since the default in ArkType is `true`, this will only have an effect if set to `false`
configure({ exactOptionalPropertyTypes: false })import "./config.ts"
// import your config file before arktype
import { type } from "arktype"
const MyObj = type({
"key?": "number"
})
// valid data
const validResult = MyObj({})
// now also valid data (would be an error by default)
const secondResult = MyObj({ key: undefined })WARNING: exactOptionalPropertyTypes does not yet affect default values!
const MyObj = type({
key: "number = 5"
})
// { key: 5 }
const omittedResult = MyObj({})
// { key: undefined }
const undefinedResult = MyObj({ key: undefined })Support for this is tracked as part of this broader configurable defaultability issue.