Skip to content

Releases: arktypeio/arktype

[email protected]

11 Jun 11:35
b114600

Choose a tag to compare

Allow overriding builtin keywords

// all references to string in this scope now enforce minLength: 1
const $ = scope({
	foo: {
		// has minLength: 1
		bar: "string"
	},
	string: schema({ domain: "string" }).constrain("minLength", 1)
})

// has minLength: 1
const s = $.type("string")

Fix a ParseError compiling certain morphs with cyclic inputs

Types like the following will now work:

const types = scope({
	ArraySchema: {
		"items?": "Schema"
	},
	Schema: "TypeWithKeywords",
	TypeWithKeywords: "ArraySchema"
}).export()

const t = types.Schema.pipe(o => JSON.stringify(o))

@arktype/[email protected]

11 Jun 11:35
b114600

Choose a tag to compare

Patch Changes

@arktype/[email protected]

06 Jun 13:52
9e7c655

Choose a tag to compare

Patch Changes

[email protected]

06 Jun 13:52
9e7c655

Choose a tag to compare

[email protected] Pre-release
Pre-release

Fix chained .describe() on union types

// now correctly adds the description to the union and its branches
const t = type("number|string").describe("My custom type")

@arktype/[email protected]

05 Jun 05:16
a7252a6

Choose a tag to compare

@arktype/[email protected]

05 Jun 05:16
a7252a6

Choose a tag to compare

Patch Changes

  • #997 232fc42 Thanks @ssalbdivad! - Add a new parseAsSchema API that accepts unknown and returns either a ParseError or a Root schema instance with a castable parameter.

    Useful for stuff like:

    const s = schema("number")
    const fromSerialized = parseAsSchema(s.json)
  • Updated dependencies [232fc42]:

@arktype/[email protected]

05 Jun 05:16
a7252a6

Choose a tag to compare

Patch Changes

[email protected]

05 Jun 05:16
a7252a6

Choose a tag to compare

[email protected] Pre-release
Pre-release

Fix autocomplete for private aliases

const $ = scope({
	"#kekw": "true",
	// now correctly completed as "kekw" without the # prefix,
	outerKek: {
		kekw: "kek"
	}
})

[email protected]

01 Jun 20:43
12b3189

Choose a tag to compare

Chainable Constraints

Added satisfying, matching, divisibleBy, atLeast, moreThan, atMost, lessThan, atLeastLength, moreThanLength, atMostLength, lessThanLength, atOrAfter, laterThan, atOrBefore, and earlierThan as chainable expressions mirroring existing comparator expressions.

This can be especially convenient for applying constraints to previously defined types like this:

const evenNumber = type("number%2")

const evenNumberLessThan100 = evenNumber.lessThan(100)

const equivalentSingleDeclaration = type("number%2<100")

Also works great for chaining off non-string-embedable expressions outside a scope:

const myBoundedArray = type({ foo: "string" })
	.array()
	.atLeastLength(5)
	.atMostLength(20)

These chained operations are also typesafe:

// TypeError: Divisor operand must be a number (was a string)
type("string").divisibleBy(2)

Cyclic Types Bug Fix

Fixed an issue causing standalone types referencing cyclic types in a scope to crash on JIT-compiled runtime validation.

Types like this will now work correctly:

const $ = scope({
	box: {
		"box?": "box"
	}
})

const box = $.type("box|null")

@arktype/[email protected]

01 Jun 20:43
12b3189

Choose a tag to compare

Patch Changes