Seems zod v4 not supported yet. Right?
Argument of type 'typeof import("/[email protected]/node_modules/zod/dist/types/v4/index")' is not assignable to parameter of type 'typeof import("/[email protected]/node_modules/zod/lib/external")'. Type 'typeof import("/[email protected]/node_modules/zod/dist/types/v4/index")' is missing the following properties from type 'typeof import("/[email protected]/node_modules/zod/lib/external")': defaultErrorMap, addIssueToContext, makeIssue, EMPTY_PATH, and 30 more.ts(2345)
import { Schema, SchemaDefinition, SchemaOptions, SchemaTypeOptions, SchemaTypes, Types } from 'mongoose';
import { z, ZodObject, ZodRawShape, ZodType } from 'zod';
declare namespace zm {
interface zID extends z.ZodUnion<[
z.ZodString,
z.ZodType<Types.ObjectId, z.ZodTypeDef, Types.ObjectId>
]> {
__zm_type: "ObjectId";
__zm_ref?: string;
__zm_refPath?: string;
ref: (ref: string) => zID;
unique: (val?: boolean) => zID;
sparse: (val?: boolean) => zID;
refPath: (ref: string) => zID;
}
The index.d.ts still imports zod instead of zod/v4. What i think needs to be done is to create a 5.x.x version of @zodyac/zod-mongoose. And the major update should focus on supporting zod v4, and should exclusively support zod v4. This is the approach for example fastify-type-provider-zod has went with, and it works good.