Skip to content

Commit b6e59c3

Browse files
committed
Check for existence of Error.captureStackTrace
1 parent b142ea8 commit b6e59c3

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

packages/zod/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zod",
3-
"version": "3.25.63",
3+
"version": "3.25.64",
44
"type": "module",
55
"author": "Colin McDonnell <[email protected]>",
66
"description": "TypeScript-first schema declaration and validation library with static type inference",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,6 +1913,7 @@ export const ZodCustom: core.$constructor<ZodCustom> = /*@__PURE__*/ core.$const
19131913
export function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O> {
19141914
const ch = new core.$ZodCheck({
19151915
check: "custom",
1916+
19161917
...util.normalizeParams(params),
19171918
});
19181919

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const _parse: (_Err: $ZodErrorClass) => $Parse = (_Err) => (schema, value
2121
}
2222
if (result.issues.length) {
2323
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
24-
Error.captureStackTrace(e, _params?.callee);
24+
util.captureStackTrace(e, _params?.callee);
2525
throw e;
2626
}
2727
return result.value as core.output<typeof schema>;
@@ -42,7 +42,7 @@ export const _parseAsync: (_Err: $ZodErrorClass) => $ParseAsync = (_Err) => asyn
4242
if (result instanceof Promise) result = await result;
4343
if (result.issues.length) {
4444
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())));
45-
Error.captureStackTrace(e, params?.callee);
45+
util.captureStackTrace(e, params?.callee);
4646
throw e;
4747
}
4848
return result.value as core.output<typeof schema>;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,7 @@ export type $strip = {
15971597
out: {};
15981598
in: {};
15991599
};
1600+
16001601
export type $catchall<T extends SomeType> = {
16011602
out: { [k: string]: core.output<T> };
16021603
in: { [k: string]: core.input<T> };
@@ -3629,7 +3630,7 @@ export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodChec
36293630
path?: PropertyKey[] | undefined;
36303631
error?: errors.$ZodErrorMap | undefined;
36313632
params?: Record<string, any> | undefined;
3632-
fn: (arg: O) => unknown; // checks.$ZodCheck<O>["_zod"]["check"];
3633+
fn: (arg: O) => unknown;
36333634
}
36343635

36353636
export interface $ZodCustomInternals<O = unknown, I = unknown>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ export function esc(str: string): string {
314314
return JSON.stringify(str);
315315
}
316316

317+
export const captureStackTrace: typeof Error.captureStackTrace = Error.captureStackTrace
318+
? Error.captureStackTrace
319+
: (..._args) => {};
320+
317321
export function isObject(data: any): data is Record<PropertyKey, unknown> {
318322
return typeof data === "object" && data !== null && !Array.isArray(data);
319323
}

play.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import { z } from "zod/v4";
22

33
z;
44

5-
console.dir(z.iso.datetime({ local: true }).parse("2025-05-21T12:00"), { depth: null });
5+
console.dir(z.toJSONSchema(z.string().meta({ id: "asdf" })), { depth: null });

0 commit comments

Comments
 (0)