Skip to content

TS5115 "infinitely circular" on .catchall(z.json()) with the TypeScript 7.1 nightlies #6637

Closed

Description

@maschwenk

the typescript 7.1 nightlies (7.1.0-dev.20260929.1 and later) report this on any .catchall(z.json()):

import { z } from 'zod'

export const schema = z.object({ n: z.number() }).catchall(z.json())
error TS5115: Instantiations of the following types appear infinitely circular: 'IsOptionalIn', '$ZodTypeInternals', '$InferZodRecordInput'.

same with zod 4.5.4 and 4.6.5. typescript 7.0.2 is fine

it comes from this typescript change, which makes the checker stricter about a type that references itself through the type arguments of its base type:

zod showed up in their top 1000 repo run for it, and anders suggested taking the type arguments off the $ZodTypeInternals base of $ZodRecordInternals and declaring input/output directly:

export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals {
    def: $ZodRecordDef<Key, Value>;
    isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
    optin?: "optional" | undefined;
    optout?: "optional" | undefined;
    output: $InferZodRecordOutput<Key, Value>;
    input: $InferZodRecordInput<Key, Value>;
}

(his comment has input: $InferZodRecordOutput, i think thats a typo since input should stay $InferZodRecordInput)

i tried that in 4.6.5's v4/core/schemas.d.ts and .d.cts. the repro is clean on both the nightly and 7.0.2, and z.input/z.output of a z.record(...) come out the same as before. PRs look limited to collaborators here so i couldn't open one, but the change plus a type test is on this branch if it's useful:

Activity

  1. parnilV06 commented on Oct 8, 2026

    @parnilV06

    Hey !
    I would like to work on this issue

  2. colinhacks commented on Oct 9, 2026

    @colinhacks
    Owner

    Fixed in #6645, which goes out in the next release. Thanks for tracking this down, @maschwenk 👍

  3. added a commit that references this issue on Oct 12, 2026
    8018726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions