diff --git a/deno/lib/__tests__/branded.test.ts b/deno/lib/__tests__/branded.test.ts index 56bd8a0bd..48ce83f5f 100644 --- a/deno/lib/__tests__/branded.test.ts +++ b/deno/lib/__tests__/branded.test.ts @@ -47,6 +47,17 @@ test("branded types", () => { true ); + // keeping brands out of input types + const age = z.number().brand<"age">(); + + type Age = z.infer; + type AgeInput = z.input; + + util.assertEqual(false); + + util.assertEqual(true); + util.assertEqual, Age>(true); + // @ts-expect-error doStuff({ name: "hello there!" }); }); diff --git a/deno/lib/types.ts b/deno/lib/types.ts index aeeb4d2d5..afb271448 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -3795,11 +3795,7 @@ export type BRAND = { export class ZodBranded< T extends ZodTypeAny, B extends string | number | symbol -> extends ZodType< - T["_output"] & BRAND, - ZodBrandedDef, - T["_input"] & BRAND -> { +> extends ZodType, ZodBrandedDef, T["_input"]> { _parse(input: ParseInput): ParseReturnType { const { ctx } = this._processInputParams(input); const data = ctx.data; diff --git a/src/__tests__/branded.test.ts b/src/__tests__/branded.test.ts index 3e7fe4d66..01b1cfa41 100644 --- a/src/__tests__/branded.test.ts +++ b/src/__tests__/branded.test.ts @@ -46,6 +46,17 @@ test("branded types", () => { true ); + // keeping brands out of input types + const age = z.number().brand<"age">(); + + type Age = z.infer; + type AgeInput = z.input; + + util.assertEqual(false); + + util.assertEqual(true); + util.assertEqual, Age>(true); + // @ts-expect-error doStuff({ name: "hello there!" }); }); diff --git a/src/types.ts b/src/types.ts index b9935121a..8d31834d2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3795,11 +3795,7 @@ export type BRAND = { export class ZodBranded< T extends ZodTypeAny, B extends string | number | symbol -> extends ZodType< - T["_output"] & BRAND, - ZodBrandedDef, - T["_input"] & BRAND -> { +> extends ZodType, ZodBrandedDef, T["_input"]> { _parse(input: ParseInput): ParseReturnType { const { ctx } = this._processInputParams(input); const data = ctx.data;