diff --git a/deno/lib/__tests__/catch.test.ts b/deno/lib/__tests__/catch.test.ts index 935c39681..f8ea89911 100644 --- a/deno/lib/__tests__/catch.test.ts +++ b/deno/lib/__tests__/catch.test.ts @@ -222,8 +222,6 @@ test("catch error", () => { test("ctx.input", () => { const schema = z.string().catch((ctx) => { - console.log(ctx.input); - console.log(ctx.error); return String(ctx.input); }); diff --git a/deno/lib/types.ts b/deno/lib/types.ts index f61e449a3..d9aecc9c5 100644 --- a/deno/lib/types.ts +++ b/deno/lib/types.ts @@ -4305,10 +4305,7 @@ export class ZodEffects< path: ctx.path, parent: ctx, }); - // if (base.status === "aborted") return INVALID; - // if (base.status === "dirty") { - // return { status: "dirty", value: base.value }; - // } + if (!isValid(base)) return base; const result = effect.transform(base.value, checkCtx); @@ -4324,10 +4321,7 @@ export class ZodEffects< ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }) .then((base) => { if (!isValid(base)) return base; - // if (base.status === "aborted") return INVALID; - // if (base.status === "dirty") { - // return { status: "dirty", value: base.value }; - // } + return Promise.resolve(effect.transform(base.value, checkCtx)).then( (result) => ({ status: status.value, value: result }) ); diff --git a/playground.ts b/playground.ts index d17b18eb4..24fb4f8f8 100644 --- a/playground.ts +++ b/playground.ts @@ -1,2 +1,8 @@ import { z } from "./src"; -z; + +function foo(schema: Schema) { + return z.object({ bar: schema }).transform((x) => x.bar); + // ^^^ + // Property 'bar' does not exist on type + // '{ [k in keyof baseObjectOutputType<{ bar: Schema; }>]: baseObjectOutputType<{ bar: Schema; }>[k]; }'. +} diff --git a/src/__tests__/catch.test.ts b/src/__tests__/catch.test.ts index 4586e4742..ae0ebe0a4 100644 --- a/src/__tests__/catch.test.ts +++ b/src/__tests__/catch.test.ts @@ -221,8 +221,6 @@ test("catch error", () => { test("ctx.input", () => { const schema = z.string().catch((ctx) => { - console.log(ctx.input); - console.log(ctx.error); return String(ctx.input); }); diff --git a/src/types.ts b/src/types.ts index 1336383ca..718d082e1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4305,10 +4305,7 @@ export class ZodEffects< path: ctx.path, parent: ctx, }); - // if (base.status === "aborted") return INVALID; - // if (base.status === "dirty") { - // return { status: "dirty", value: base.value }; - // } + if (!isValid(base)) return base; const result = effect.transform(base.value, checkCtx); @@ -4324,10 +4321,7 @@ export class ZodEffects< ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }) .then((base) => { if (!isValid(base)) return base; - // if (base.status === "aborted") return INVALID; - // if (base.status === "dirty") { - // return { status: "dirty", value: base.value }; - // } + return Promise.resolve(effect.transform(base.value, checkCtx)).then( (result) => ({ status: status.value, value: result }) );