Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ark/attest/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

NOTE: This changelog is incomplete, but will include notable attest-specific changes (many updates consist almost entirely of bumped `arktype` versions for assertions).

## 0.57.1

### Support TypeScript 7.1 beta

TypeScript 7.1 moved its native API from `typescript/unstable/*` to `typescript/*`, starting with `7.1.0-dev.20261009.1`. Attest now imports the new paths, so it works with `typescript@7.1.0-beta` and later rather than failing with `Package subpath './unstable/ast' is not defined by "exports"`. 7.1 nightlies from before `20261009` are no longer supported.

### Add `onlyNamedTestFiles`

With `onlyNamedTestFiles`, attest only analyzes the `*.test.*` files named on the command line rather than every file in your project, so type checking a single file takes seconds instead of minutes. Pair it with a runner invocation that only runs those files, like mocha's `--no-package`. Otherwise, the tests from files that weren't analyzed fail with "Found no assertion data".

```sh
mocha --onlyNamedTestFiles --no-package ./src/__tests__/user.test.ts
```

## 0.57.0

### Breaking changes
Expand Down
4 changes: 2 additions & 2 deletions ark/attest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/attest",
"version": "0.57.0",
"version": "0.57.1",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down Expand Up @@ -52,7 +52,7 @@
"devDependencies": {
"typescript": "catalog:",
"typescript-6": "npm:typescript@6.0.3",
"typescript-7": "npm:typescript@7.1.0-dev.20261006.1"
"typescript-7": "npm:typescript@7.1.0-beta"
},
"peerDependencies": {
"typescript": "*"
Expand Down
12 changes: 6 additions & 6 deletions ark/attest/ts7/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { createRequire } from "node:module"
import { dirname, join, resolve } from "node:path"
import { threadId } from "node:worker_threads"
import ts from "typescript"
import type * as tsgoAst from "typescript/unstable/ast"
import type * as tsgoFs from "typescript/unstable/fs"
import type * as tsgoApi from "typescript/unstable/sync"
import type * as tsgoAst from "typescript/ast"
import type * as tsgoFs from "typescript/fs"
import type * as tsgoApi from "typescript/sync"
import type { LinePositionRange } from "../cache/getCachedAssertions.ts"
import { getConfig } from "../config.ts"
import { isTs7, narrowToNamedTestFiles } from "../utils.ts"
Expand All @@ -17,13 +17,13 @@ const requireTypeScript = createRequire(import.meta.url)

// only loaded for TS 7+ so this module can be imported unconditionally
export const ast: typeof tsgoAst =
isTs7 ? requireTypeScript("typescript/unstable/ast") : (undefined as never)
isTs7 ? requireTypeScript("typescript/ast") : (undefined as never)

const { API, TypeFormatFlags }: typeof tsgoApi =
isTs7 ? requireTypeScript("typescript/unstable/sync") : ({} as never)
isTs7 ? requireTypeScript("typescript/sync") : ({} as never)

const { createFileSystemLayer }: typeof tsgoFs =
isTs7 ? requireTypeScript("typescript/unstable/fs") : ({} as never)
isTs7 ? requireTypeScript("typescript/fs") : ({} as never)

export const noTruncation: number = isTs7 ? TypeFormatFlags.NoTruncation : 0

Expand Down
2 changes: 1 addition & 1 deletion ark/fast-check/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/fast-check",
"version": "0.0.19",
"version": "0.0.20",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down
2 changes: 1 addition & 1 deletion ark/fs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/fs",
"version": "0.56.7",
"version": "0.56.8",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down
2 changes: 1 addition & 1 deletion ark/json-schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/json-schema",
"version": "0.0.12",
"version": "0.0.13",
"license": "MIT",
"authors": [
{
Expand Down
14 changes: 14 additions & 0 deletions ark/regex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# arkregex

## 0.0.14

### allow `}` to be escaped

`\}` was a type error as an unnecessary escape, though the `u` and `v` flags require it to match `}` literally (#1691).

```ts
// was: type error
// now: Regex<"a{b}", { flags: "u" }>
regex("^a\\{b\\}$", "u")
```

Thanks to @cpruijsen.

## 0.0.6

### include the empty string when a zero-min quantifier applies to a number pattern
Expand Down
2 changes: 1 addition & 1 deletion ark/regex/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arkregex",
"description": "A drop-in replacement for new RegExp() with types",
"version": "0.0.13",
"version": "0.0.14",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion ark/schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/schema",
"version": "0.56.7",
"version": "0.56.8",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down
97 changes: 97 additions & 0 deletions ark/type/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,102 @@
# arktype

## 2.2.9

### Keep tuple elements around defaults in `.in` and `.out`

Combining a tuple's defaultable elements with its other elements dropped some of them, depending on key order:

```ts
const T = type(["string", "number = 5", "boolean?"])

// was: [string, boolean?]
// now: [string, number?, boolean?]
T.in.expression

// was: number[]
// now: [number, string, ...number[]]
type(["number", "string = 'foo'", "...", "number[]"]).out.expression
```

A bound that narrows two existing length constraints at once also no longer throws "multiple distinct intersection results":

```ts
// was: throws
// now: string == 2
type("1 <= string <= 2").and("string >= 2")
```

Thanks to @ybai08 (#1696).

### Reject `NaN` in unions discriminated by `typeof`

`number` rejects `NaN`, but compiled unions like `number | null` dropped that check when they discriminated by `typeof`, so `NaN` was only rejected with `jitless` (#1702).

```ts
const T = type("number | null")

// was: NaN
// now: ArkErrors: must be a number (was NaN)
T(NaN)
```

Thanks to @thecotne.

### Don't treat `Object.prototype` keys as declared

Inherited names like `toString` or `constructor`, and an own `__proto__` key like the one `JSON.parse` creates, were treated as declared keys, so `"+": "delete"` kept them and `"+": "reject"` accepted them (#1701).

```ts
const T = type({ a: "string", "+": "reject" })

// was: { a: "x", constructor: 1 }
// now: ArkErrors: constructor must be removed
T({ a: "x", constructor: 1 })
```

Thanks to @thecotne.

### Only emit referenced `$defs` in `toJsonSchema`

With `useRefs`, or for a cyclic type, every node a type referenced was written to `$defs`, including discriminated union cases that never appear in the output. Some of those couldn't be converted, so `toJsonSchema()` threw `Unexpected JSON Schema input for structure: {}` (#1689, fixes #1612, #1511 and #1546).

```ts
const T = type.or(
{ a: type.enumerated("a", "b", "c"), b: "1" },
{ a: type.enumerated("a", "e", "f"), b: "2" }
)

// was: throws
// now: only the $defs that a $ref points to
T.toJsonSchema({ useRefs: true })
```

Thanks to @giaBaoJS.

### Convert unrepresentable types in `~standard.jsonSchema` instead of throwing

`~standard.jsonSchema.input` and `.output` now throw only for an unsupported `target`, i.e. one other than `draft-2020-12` or `draft-07`. Parts of a type that JSON Schema can't represent are converted instead (#1694):

- a predicate, a second pattern, a `Date` bound or an array's non-index props is dropped from the schema it constrains
- `bigint`, `symbol`, a non-JSON unit like `undefined` and any prototype other than `Array` become `{}`
- a variadic tuple with postfix elements keeps its prefix and `minItems`, but not its `items`
- a default that isn't JSON is omitted

```ts
const T = type({
big: "bigint",
even: type("number").narrow(n => n % 2 === 0)
})

// was: throws
// now: { type: "object", properties: { big: {}, even: { type: "number" } }, ... }
T["~standard"].jsonSchema.input({ target: "draft-2020-12" })
```

Fallbacks from a scope's `toJsonSchema` config or from `libraryOptions` still take precedence, and `toJsonSchema()` itself still throws by default.

A `defaultValue` fallback can now return `undefined` to omit the default rather than writing `default: undefined`.

## 2.2.8

### Add `string.base58`
Expand Down
2 changes: 1 addition & 1 deletion ark/type/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arktype",
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
"version": "2.2.8",
"version": "2.2.9",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion ark/util/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/util",
"version": "0.56.7",
"version": "0.56.8",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion ark/util/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { FileConstructor, objectKindOf } from "./objectKinds.ts"
// recent node versions (https://nodejs.org/api/esm.html#json-modules).

// For now, we assert this matches the package.json version via a unit test.
export const arkUtilVersion = "0.56.7"
export const arkUtilVersion = "0.56.8"

export const initialRegistryContents = {
version: arkUtilVersion,
Expand Down
Loading
Loading