Skip to content

Releases: arktypeio/arktype

[email protected]

13 Jun 23:50
1aa6064
Compare
Choose a tag to compare

Fix constrained narrow/pipe tuple expression input inference

Previously constraints were not stripped when inferring function inputs for tuple expressions like the following:

// previously errored due to data being inferred as `number.moreThan<0>`
// now correctly inferred as number
const t = type(["number>0", "=>", data => data + 1])

Fix a bug where paths including optional keys could be included as candidates for discrimination (see #960)

Throw descriptive parse errors on unordered unions between indiscriminable morphs and other indeterminate type operations (see #967)

@arktype/[email protected]

13 Jun 23:50
1aa6064
Compare
Choose a tag to compare

Patch Changes

@arktype/[email protected]

13 Jun 23:50
1aa6064
Compare
Choose a tag to compare

Patch Changes

@arktype/[email protected]

13 Jun 23:50
1aa6064
Compare
Choose a tag to compare

Minor Changes

  • #1011 2be4f5b Thanks @ssalbdivad! - ### Throw by default when attest.instantiations() exceeds the specified benchPercentThreshold

    Tests like this will now correctly throw inline instead of return a non-zero exit code:

    it("can snap instantiations", () => {
    	type Z = makeComplexType<"asbsdfsaodisfhsda">
    	// will throw here as the actual number of instantiations is more
    	// than 20% higher than the snapshotted value
    	attest.instantiations([1, "instantiations"])
    })

    Snapshotted completions will now be alphabetized

    This will help improve stability, especially for large completion lists like this one which we updated more times than we'd care to admit 😅

    attest(() => type([""])).completions({
    	"": [
    		"...",
    		"===",
    		"Array",
    		"Date",
    		"Error",
    		"Function",
    		"Map",
    		"Promise",
    		"Record",
    		"RegExp",
    		"Set",
    		"WeakMap",
    		"WeakSet",
    		"alpha",
    		"alphanumeric",
    		"any",
    		"bigint",
    		"boolean",
    		"creditCard",
    		"digits",
    		"email",
    		"false",
    		"format",
    		"instanceof",
    		"integer",
    		"ip",
    		"keyof",
    		"lowercase",
    		"never",
    		"null",
    		"number",
    		"object",
    		"parse",
    		"semver",
    		"string",
    		"symbol",
    		"this",
    		"true",
    		"undefined",
    		"unknown",
    		"uppercase",
    		"url",
    		"uuid",
    		"void"
    	]
    })

Patch Changes

[email protected]

12 Jun 23:16
c1f9431
Compare
Choose a tag to compare

Add an AnyType type that allows a Type instance from any Scope

Avoid an overly verbose default error on a missing key for a complex object

const MyType = type({
	foo: {
		/** Some very complex object */
	}
})

// previously threw with a message like:
// sections must be /* Some very complex description */ (was missing)

// now throws with a message like:
// sections must be an object (was missing)
MyType.assert({})

@arktype/[email protected]

12 Jun 23:16
c1f9431
Compare
Choose a tag to compare

Patch Changes

[email protected]

11 Jun 11:35
b114600
Compare
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
Compare
Choose a tag to compare

Patch Changes

@arktype/[email protected]

06 Jun 13:52
9e7c655
Compare
Choose a tag to compare

Patch Changes

[email protected]

06 Jun 13:52
9e7c655
Compare
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")