Skip to content

Commit 98cd8b3

Browse files
committed
Fix more excessively deep
1 parent 50e9afb commit 98cd8b3

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ export interface $ZodTypeInternals<out O = unknown, out I = unknown> {
151151
parent?: $ZodType | undefined;
152152
}
153153

154+
export type $ZodStandardSchema<T extends $ZodType> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
155+
154156
export interface $ZodType<O = unknown, I = unknown> {
155157
_zod: $ZodTypeInternals<O, I>;
156-
"~standard": StandardSchemaV1.Props<core.input<this>, core.output<this>>;
158+
"~standard": $ZodStandardSchema<this>;
157159
}
158160

159161
export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {

play.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { z } from "zod/v4";
1+
// import { z } from "zod/v4";
22

3-
z;
4-
const recordWithBrandedNumberKeys = z.record(z.number().brand("SomeBrand"), z.number());
5-
type recordWithBrandedNumberKeys = z.infer<typeof recordWithBrandedNumberKeys>;
3+
import type { z } from "zod/v4";
4+
5+
export type RefinedSchema<T extends z.core.$ZodType | z.core.$ZodUnion = z.core.$ZodType | z.core.$ZodUnion> =
6+
T extends z.core.$ZodUnion
7+
? RefinedUnionSchema<T> // <-- Type instantiation is excessively deep and possibly infinite.
8+
: never;
9+
10+
export type RefinedTypeSchema<T extends object> = T;
11+
export type RefinedUnionSchema<T extends z.core.$ZodUnion> = T;

0 commit comments

Comments
 (0)