Skip to content

Releases: arktypeio/arktype

2.0.4

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare

Fix an issue causing global configs to be overwritten when the primary "arktype" entry point is imported:

config.ts

import { configure } from "arktype/config"

configure({ numberAllowsNaN: true })

main.ts

import "./config.ts"
import { type } from "arktype"
// now correctly allows NaN
type.number.allows(Number.NaN)

Previous versions of the docs mistakenly suggested this was possible in a single file. This is not the case in ESM due to hoisting. See the updated global configuration docs here.

Better ParseError when attempting to constraint a morph

Previously, attempting to directly constrain a transformed type was not a type error but gave a confusing error at runtime:

// ParseError: MinLength operand must be a string or an array (was never)
type("string.trim > 2")

We've added a type error and improved the runtime error:

// TypeScript: To constrain the output of string.trim, pipe like myMorph.to('number > 0')
// ParseError: MinLength operand must be a string or an array (was a morph)
type("string.trim > 2")

Fix an issue causing certain complex morph types to not infer output correctly, e.g.:

const types = type.module({
	From: { a: ["1", "=>", () => 2] },
	Morph: ["From", "=>", e => e],
	To: { a: "2" }
})
const U = types.Morph.pipe(e => e, types.To)

// was:
//    (In: never) => To<{ a: 2 }>
// now fixed to:
//    { a: 2 }
const out = U.assert({ a: 1 })

@arktype/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@arktype/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@arktype/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@arktype/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@ark/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@ark/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@ark/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@ark/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)

@ark/[email protected]

29 Jan 03:18
bb5fbf2
Compare
Choose a tag to compare
fix: global config resolution, some inference (#1282)