diff --git a/zod-plugin/CHANGELOG.md b/zod-plugin/CHANGELOG.md index c58bd02d3e..238a77ce71 100644 --- a/zod-plugin/CHANGELOG.md +++ b/zod-plugin/CHANGELOG.md @@ -2,6 +2,11 @@ ## Version 4 +### v4.1.0 + +- Added `x-brand` type to the augmentation of Zod's `GlobalMeta` interface: + - The property is used to store the brand of the schema when using the `ZodType::brand()` method. + ### v4.0.1 - Removed debug-level comments from the declaration files in the distribution. diff --git a/zod-plugin/src/augmentation.ts b/zod-plugin/src/augmentation.ts index d09cd553f7..9f166fbf6f 100644 --- a/zod-plugin/src/augmentation.ts +++ b/zod-plugin/src/augmentation.ts @@ -1,10 +1,12 @@ import type { z } from "zod"; import type { Intact, Remap } from "./remap"; +import type { brandProperty } from "./brand"; declare module "zod/v4/core" { interface GlobalMeta { default?: unknown; // can be an actual value or a label like "Today" examples?: unknown[]; // see zod commit ee5615d + [brandProperty]?: symbol | string | number; } } diff --git a/zod-plugin/tests/index.spec.ts b/zod-plugin/tests/index.spec.ts index 50f6cee965..88116b5df1 100644 --- a/zod-plugin/tests/index.spec.ts +++ b/zod-plugin/tests/index.spec.ts @@ -1,4 +1,4 @@ -import { z } from "zod"; +import { globalRegistry, z } from "zod"; import * as entrypoint from "../src"; describe("Entrypoint", () => { @@ -13,6 +13,18 @@ describe("Entrypoint", () => { .toHaveProperty("label") .toEqualTypeOf<(value: string) => z.ZodDefault>(); expectTypeOf().toHaveProperty("remap"); + expectTypeOf>() + .exclude(undefined) + .toHaveProperty("default") + .toEqualTypeOf(); + expectTypeOf>() + .exclude(undefined) + .toHaveProperty("examples") + .toEqualTypeOf(); + expectTypeOf>() + .exclude(undefined) + .toHaveProperty("x-brand") + .toEqualTypeOf(); }); test("Exports", () => {