π Search Terms
TS5115, "appear infinitely circular", base type arguments, zod, 64372
π Version & Regression Information
β― Playground Link
No response
π» Code
interface Internals<I = unknown> { input: I }
interface Schema { _zod: Internals }
type RecordInput<V extends Schema> = V extends unknown ? Record<string, V["_zod"]["input"]> : never;
interface RecordSchema<V extends Schema> extends Schema { _zod: Internals<RecordInput<V>> }
interface UnionInternals<T extends readonly Schema[]> extends Internals<T[number]["_zod"]["input"]> {}
interface UnionSchema<T extends readonly Schema[]> extends Schema { _zod: UnionInternals<T> }
type JsonValue = { [k: string]: JsonValue };
type _Json = UnionSchema<[RecordSchema<Json>]>;
type _JsonInternals = _Json["_zod"];
interface JsonInternals extends _JsonInternals { input: JsonValue }
interface Json extends _Json { _zod: JsonInternals }
With the published package (zod@4.6.5, skipLibCheck: true):
import * as z from "zod";
export const A = z.array(z.json()); // TS5115
π Actual behavior
TS5115 "Instantiations of the following types appear infinitely circular" on RecordSchema<Json>. The same shape is Zod's z.json() type, so Zod 4.5.0 through 4.6.5 fail on 7.1:
- with
skipLibCheck: false, every project that imports Zod gets TS5115 from Zod's own declarations
- with
skipLibCheck: true, z.array(z.json()), z.record(z.string(), z.json()) or .parse() on an object holding z.json() reports it in user code, and the record's input type becomes Record<string, any>
π Expected behavior
No error, as in 7.0.2.
Additional information about the issue
Those versions get about 62M of Zod's 365M weekly npm downloads. The member-declaration fix from #64372 (comment) is merged in colinhacks/zod#6645 and goes out in the next Zod release, but projects that stay on 4.5.0β4.6.5 will still break when they move to 7.1.
π Search Terms
TS5115, "appear infinitely circular", base type arguments, zod, 64372
π Version & Regression Information
resolveObjectTypeMembersΒ #64372, first in7.1.0-dev.20260929.1.7.0.2and the commit before Restore idempotency toresolveObjectTypeMembersΒ #64372 are fine. Still present in7.1.0-dev.20261002.1.β― Playground Link
No response
π» Code
With the published package (
zod@4.6.5,skipLibCheck: true):π Actual behavior
TS5115 "Instantiations of the following types appear infinitely circular" on
RecordSchema<Json>. The same shape is Zod'sz.json()type, so Zod 4.5.0 through 4.6.5 fail on 7.1:skipLibCheck: false, every project that imports Zod gets TS5115 from Zod's own declarationsskipLibCheck: true,z.array(z.json()),z.record(z.string(), z.json())or.parse()on an object holdingz.json()reports it in user code, and the record's input type becomesRecord<string, any>π Expected behavior
No error, as in 7.0.2.
Additional information about the issue
Those versions get about 62M of Zod's 365M weekly npm downloads. The member-declaration fix from #64372 (comment) is merged in colinhacks/zod#6645 and goes out in the next Zod release, but projects that stay on 4.5.0β4.6.5 will still break when they move to 7.1.