Closed MickL closed 4 hours ago
Are you using TypeScript's strict mode? See the docs.
Also, your example has some small typos that might be causing issues.
export const myMsgSchema = z.object({
message: z.string(),
count: z.number().positive(),
});
export type MyMsg = z.output<typeof myMsgSchema>; // Fixed capitalization
const msg: MyMsg = {
message: "hello", // Changed to comma
};
With strict mode, your example is giving me an error.
The typos were because I created the example out of my code.
strict mode "fixed" it, thanks.
Using
z.output
, ALL properties optional. E.g. the following should throw a TypeScript error thatcount
is required but it does not: