Skip to content

z.preprocess() produces invalid syntax output #4

@ismailkarsli

Description

@ismailkarsli

Thanks for the package. While migrating to it, I encountered to an issue. When preprocess is used, the lib produces an invalid output. Here's demonstration:

import { serialize } from "@zod-codepen/zod-v4";
import { z } from "zod";
import { stringToArray } from "./utils.ts";

const Schema = z.object({
	items: z.preprocess((val) => stringToArray(val), z.array(z.string())),
});

const code = serialize(Schema);
// Output:
const generatedCode = z.object({
  items: /* transform */.pipe(z.array(z.string())),
})

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions