Skip to content

Commit fb6b0a7

Browse files
author
Colin McDonnell
committed
Fix Deno bundle error
1 parent cbfe704 commit fb6b0a7

File tree

7 files changed

+25
-17
lines changed

7 files changed

+25
-17
lines changed

deno/lib/ZodError.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,12 @@ export const defaultErrorMap = (
413413
return { message };
414414
};
415415

416-
export let overrideErrorMap = defaultErrorMap;
416+
let overrideErrorMap = defaultErrorMap;
417417

418-
export const setErrorMap = (map: ZodErrorMap) => {
418+
export function setErrorMap(map: ZodErrorMap) {
419419
overrideErrorMap = map;
420-
};
420+
}
421+
422+
export function getErrorMap() {
423+
return overrideErrorMap;
424+
}

deno/lib/helpers/parseUtil.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError.ts";
2-
import { defaultErrorMap, overrideErrorMap } from "../ZodError.ts";
2+
import { defaultErrorMap, getErrorMap } from "../ZodError.ts";
33
import type { ZodParsedType } from "./util.ts";
44

55
export const makeIssue = (params: {
@@ -71,7 +71,7 @@ export function addIssueToContext(
7171
errorMaps: [
7272
ctx.common.contextualErrorMap, // contextual error map is first priority
7373
ctx.schemaErrorMap, // then schema-bound map if available
74-
overrideErrorMap, // then global override map
74+
getErrorMap(), // then global override map
7575
defaultErrorMap, // then global default map
7676
].filter((x) => !!x) as ZodErrorMap[],
7777
});

deno/lib/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { Primitive } from "./helpers/typeAliases.ts";
2323
import { getParsedType, util, ZodParsedType } from "./helpers/util.ts";
2424
import {
2525
defaultErrorMap,
26+
getErrorMap,
2627
IssueData,
27-
overrideErrorMap,
2828
StringValidation,
2929
ZodCustomIssue,
3030
ZodError,
@@ -2823,7 +2823,7 @@ export class ZodFunction<
28232823
errorMaps: [
28242824
ctx.common.contextualErrorMap,
28252825
ctx.schemaErrorMap,
2826-
overrideErrorMap,
2826+
getErrorMap(),
28272827
defaultErrorMap,
28282828
].filter((x) => !!x) as ZodErrorMap[],
28292829
issueData: {
@@ -2840,7 +2840,7 @@ export class ZodFunction<
28402840
errorMaps: [
28412841
ctx.common.contextualErrorMap,
28422842
ctx.schemaErrorMap,
2843-
overrideErrorMap,
2843+
getErrorMap(),
28442844
defaultErrorMap,
28452845
].filter((x) => !!x) as ZodErrorMap[],
28462846
issueData: {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zod",
3-
"version": "3.17.5",
3+
"version": "3.17.6",
44
"description": "TypeScript-first schema declaration and validation library with static type inference",
55
"main": "./lib/index.js",
66
"types": "./index.d.ts",

src/ZodError.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,12 @@ export const defaultErrorMap = (
413413
return { message };
414414
};
415415

416-
export let overrideErrorMap = defaultErrorMap;
416+
let overrideErrorMap = defaultErrorMap;
417417

418-
export const setErrorMap = (map: ZodErrorMap) => {
418+
export function setErrorMap(map: ZodErrorMap) {
419419
overrideErrorMap = map;
420-
};
420+
}
421+
422+
export function getErrorMap() {
423+
return overrideErrorMap;
424+
}

src/helpers/parseUtil.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
2-
import { defaultErrorMap, overrideErrorMap } from "../ZodError";
2+
import { defaultErrorMap, getErrorMap } from "../ZodError";
33
import type { ZodParsedType } from "./util";
44

55
export const makeIssue = (params: {
@@ -71,7 +71,7 @@ export function addIssueToContext(
7171
errorMaps: [
7272
ctx.common.contextualErrorMap, // contextual error map is first priority
7373
ctx.schemaErrorMap, // then schema-bound map if available
74-
overrideErrorMap, // then global override map
74+
getErrorMap(), // then global override map
7575
defaultErrorMap, // then global default map
7676
].filter((x) => !!x) as ZodErrorMap[],
7777
});

src/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { Primitive } from "./helpers/typeAliases";
2323
import { getParsedType, util, ZodParsedType } from "./helpers/util";
2424
import {
2525
defaultErrorMap,
26+
getErrorMap,
2627
IssueData,
27-
overrideErrorMap,
2828
StringValidation,
2929
ZodCustomIssue,
3030
ZodError,
@@ -2823,7 +2823,7 @@ export class ZodFunction<
28232823
errorMaps: [
28242824
ctx.common.contextualErrorMap,
28252825
ctx.schemaErrorMap,
2826-
overrideErrorMap,
2826+
getErrorMap(),
28272827
defaultErrorMap,
28282828
].filter((x) => !!x) as ZodErrorMap[],
28292829
issueData: {
@@ -2840,7 +2840,7 @@ export class ZodFunction<
28402840
errorMaps: [
28412841
ctx.common.contextualErrorMap,
28422842
ctx.schemaErrorMap,
2843-
overrideErrorMap,
2843+
getErrorMap(),
28442844
defaultErrorMap,
28452845
].filter((x) => !!x) as ZodErrorMap[],
28462846
issueData: {

0 commit comments

Comments
 (0)