Closed
Description
In @zod/mini
, both extend
and merge
lose schema type information and resolve to a plain object, breaking inference.
import * as z from "@zod/mini";
const Test = z.object({
test: z.string(),
});
const Test2 = z.extend(Test, {
test2: z.string(),
});
type Test2 = z.infer<typeof Test2>;
const test2 = {} as Test2;
console.log(test2.test);
console.log(test2.test2);
Errors:
Property 'test' does not exist on type 'object'.
Property 'test2' does not exist on type 'object'.
Workaround
Using .intersection()
works but is not compatible with ZodMiniObject
and introduces other type issues.
Expected
extend
and merge
should preserve the schema and allow proper type inference like in zod.
Metadata
Metadata
Assignees
Labels
No labels