Packages

arktype

2.2.9 · 20 Oct 2026MIT3.4M / weekRepositoryHomepagenpmAtom feed

Your version

2.2.6

30 Sep 2026Where it was published

2.2.9 is the newest release of 2.x.

Release note

The section about arktype of a note shared by several packages.

Add ArkErrors.message

ArkErrors now has a message getter returning the same human-readable string as summary, so code that handles a failed result like an Error gets a useful message instead of undefined:

const out = T(data)
if (out instanceof type.errors) console.error(out.message)

Fix a crash when ctx.reject without expected fails in a union

Rejecting from a narrow without an expected value could throw a TypeError instead of returning errors when the failure occurred in a union that could not be discriminated:

const T = type("string[] | Function").narrow(
	(v, ctx) => Array.isArray(v) || ctx.reject({ problem: "custom" })
)

// previously threw "Cannot read properties of undefined (reading 'name')"
T(() => {})

Predicate errors now have an explicit expected default that does not depend on the predicate being present in the error context.

Preserve narrows on piped union branches through an intersection

Intersecting a union containing a piped and narrowed branch with another morph could drop that branch's narrow:

const T = type({
	kind: "'a'",
	value: type("string.numeric.parse").narrow(
		(n, ctx) => n > 0 || ctx.mustBe("positive")
	)
})
	.or({ kind: "'b'" })
	.and(type("object").pipe(o => o))

// previously passed, now fails with "value must be positive (was -1)"
T({ kind: "a", value: "-1" })

Format times in Date error messages independent of locale

Times in Date descriptions (e.g. must be after 2:30 PM, January 15, 2023) are now consistently formatted in 12-hour time rather than depending on the runtime's default locale, which previously produced output like 14:30, January 15, 2023 in 24-hour locales. Thanks to @WolfieLeader.