Packages

arktype

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

Your version

2.1.13

26 Mar 2025Where it was published

2.2.9 is the newest release of 2.x.

Release note

Add standalone functions for n-ary operators

//  accept ...definitions
const union = type.or(type.string, "number", { key: "unknown" })

const base = type({
	foo: "string"
})

// accepts ...definitions
const intersection = type.and(
	base,
	{
		bar: "number"
	},
	{
		baz: "string"
	}
)

const zildjian = Symbol()

const base = type({
	"[string]": "number",
	foo: "0",
	[zildjian]: "true"
})

// accepts ...objectDefinitions
const merged = type.merge(
	base,
	{
		"[string]": "bigint",
		"foo?": "1n"
	},
	{
		includeThisPropAlso: "true"
	}
)

// accepts ...morphsOrTypes
const trimStartToNonEmpty = type.pipe(
	type.string,
	s => s.trimStart(),
	type.string.atLeastLength(1)
)