Skip to content

Commit e626087

Browse files
ssalbdivadclaude
andcommitted
test(json-schema): don't export recursive inferred values under TS 7.1
TS 7.1 rejects declaration emit of anonymous cyclic types (TS5088) that TS 5 and 6 elided to `any` (microsoft/TypeScript#64656), so the exported recursive values that checked declaration emit could name inference's internal aliases fail the root type check. They are unexported like the cyclic scope in tsCompat, and infer.test.ts's copy of jsonSchema.test.ts's tree is removed. A user who exports a recursive inferred schema with `declaration` enabled under TS 7.1 hits the same error, as with a cyclic arktype scope. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 4cf491f commit e626087

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎ark/json-schema/__tests__/infer.test.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ const inferred = <const schema, r = jsonSchema.infer<schema>>(
99
schema: jsonSchema.validate<schema>
1010
): r extends infer _ ? _ : never => schema as never
1111

12-
// declaration emit must be able to name the internal aliases of recursive types
13-
export const tree = inferred({
14-
type: "object",
15-
properties: {
16-
value: { type: "number" },
17-
children: { type: "array", items: { $ref: "#" } }
18-
}
19-
})
20-
2112
contextualize(() => {
2213
describe("objects", () => {
2314
it("properties and required", () => {

‎ark/json-schema/__tests__/jsonSchema.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import {
66
} from "@ark/json-schema"
77
import type { JsonSchema } from "arktype"
88

9-
// declaration emit must be able to name the internal aliases of recursive types
10-
export const tree = jsonSchema({
9+
// not exported, since TS 7.1 rejects declaration emit for anonymous cyclic
10+
// types (TS5088) that earlier versions elided to `any`
11+
// https://github.com/microsoft/TypeScript/issues/64656
12+
const tree = jsonSchema({
1113
type: "object",
1214
properties: {
1315
value: { type: "number" },

‎ark/json-schema/__tests__/roundTrip.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ const pair = (type.module as unknown as (def: object) => { pair: type.Any })({
5454

5555
const strings = (n: number) => Array<"string">(n).fill("string")
5656

57-
// declaration emit of a generated draft-07 document with a recursive
58-
// definition and a structured const
59-
export const generatedDraft07 = jsonSchema({
57+
// a generated draft-07 document with a recursive definition and a structured
58+
// const (not exported, since TS 7.1 rejects declaration emit for anonymous
59+
// cyclic types: https://github.com/microsoft/TypeScript/issues/64656)
60+
const generatedDraft07 = jsonSchema({
6061
$schema: "http://json-schema.org/draft-07/schema#",
6162
$ref: "#/definitions/Node",
6263
definitions: {

0 commit comments

Comments
 (0)