Skip to content

Commit a2ba4a6

Browse files
authored
fix(types): declare record output and input as members, not base type arguments (#6645)
microsoft/TypeScript#64372 stops base type arguments from reading the members of the interface being declared, so z.json(), whose record branch refers back to the JSON schema, reported TS5115 and inferred a record input of any.
1 parent c42596b commit a2ba4a6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/zod/src/v4/core/schemas.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3218,8 +3218,11 @@ export type $InferZodRecordInput<
32183218
: Record<core.input<Key> & PropertyKey, core.input<Value>>;
32193219

32203220
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
3221-
extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
3221+
extends $ZodTypeInternals {
32223222
def: $ZodRecordDef<Key, Value>;
3223+
// members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
3224+
output: $InferZodRecordOutput<Key, Value>;
3225+
input: $InferZodRecordInput<Key, Value>;
32233226
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
32243227
optin?: "optional" | undefined;
32253228
optout?: "optional" | undefined;

0 commit comments

Comments
 (0)