Skip to content

TS5115 on Zod 4.5 to 4.6.5 z.json() types (inherited from upstream, still open there) #20

Description

@RedesignedRobot

tsc-rs 0.1.0 reports TS5115 on any z.infer of an object that holds z.json(), with Zod 4.5.0 through 4.6.5. tsc 7.0.2 checks the same code clean. The port is faithful here: the Go checker at the pin (microsoft/TypeScript@673a5f17) prints the same error, so I'm filing it for tracking, not as a port bug.

Repro

index.ts, with zod@4.6.5 installed:

import * as z from "zod";

const item = z.object({ data: z.json() });

export const x: z.infer<typeof item> = { data: 1 };

tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "module": "preserve",
    "moduleResolution": "bundler",
    "target": "esnext",
    "skipLibCheck": true
  },
  "files": ["index.ts"]
}

tsc -p . --pretty false

Output

index.ts(5,40): error TS5115: Instantiations of the following types appear infinitely circular: '$ZodTypeInternals', '$InferZodRecordInput', 'IsOptionalIn'.

Versions

Checker Result
tsc-rs 0.1.0 (darwin-arm64 release) TS5115
Go cmd/tsc built at the pin, microsoft/TypeScript@673a5f17 same TS5115
Go cmd/tsc at 19dadef8 (microsoft/TypeScript#64372) same TS5115
Go cmd/tsc at 21b3aeb3, the parent of 19dadef8 clean
typescript 7.0.2 and 7.1.0-dev.20260928.1 clean
typescript 7.1.0-dev.20260929.1 through 7.1.0-dev.20261007.1 same TS5115

Upstream status

microsoft/TypeScript#64372 ("Restore idempotency to resolveObjectTypeMembers") introduced it. Zod's author filed microsoft/TypeScript#64605, which is open, and merged a Zod-side fix in colinhacks/zod#6645 for the next Zod release. Until one of those lands, Zod 4.5.0 to 4.6.5 users see this error with tsc-rs. In a larger project, which call sites get flagged depends on check order, because the error fires at the 100-deep instantiation limit (instantiate_type_with_alias, crates/ts_goport/src/checker/checker_p24.rs:1799).

Activity

  1. added
    upstream issueAlso happens in tsgo at the pinned upstream revision; fixed by a later pin bump
    on Oct 7, 2026
  2. t3dotgg commented on Oct 7, 2026

    @t3dotgg
    Member

    Thanks for the careful report and the bisect, @RedesignedRobot.

    Confirmed: with zod@4.6.5 and your tsconfig, tsc-rs and tsc built at the pinned revision, microsoft/TypeScript 673a5f17d713, print the same TS5115, byte for byte. So this is upstream behavior from microsoft/TypeScript#64372, as you found, and not a port bug.

    We keep this issue open to track microsoft/TypeScript#64605 and the Zod-side fix in colinhacks/zod#6645. tsc-rs gets an upstream fix with the pin bump after upstream merges one. With the Zod release that has colinhacks/zod#6645, the error should go away in tsc-rs too.

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

    upstream issueAlso happens in tsgo at the pinned upstream revision; fixed by a later pin bump

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions