zod icon indicating copy to clipboard operation
zod copied to clipboard

Can `ZodType` generic default be changed to `unknown`?

Open davidjbng opened this issue 2 years ago • 1 comments

Proposed Change

class ZodType<
-  Output = any,
+  Output = unknown,
  Def extends ZodTypeDef = ZodTypeDef,
  Input = Output

Example

I have seen this kind of wrapper function where z.Schema is missing the generic

// returns any
function parse(value: unknown, schema: z.Schema) {
  // do some other stuff ...
  return schema.parse(value)
}

I think it would be safer, if this function would return unknown by default.

Is there a reason why the generic in ZodType needs to defaults to any besides ergonomics?

Feel free to close or turn this into a discussion :)

davidjbng avatar Oct 07 '22 15:10 davidjbng

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 07 '22 02:12 stale[bot]