colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.98k stars 1.19k forks source link

object.props "required" but z.infer<T> returns "optional" type? #3544

Closed 3fatty closed 5 months ago

3fatty commented 5 months ago

deps: typescript@4.9.4 zod@3.23.8

code:

image

ps: the "parse" & "safeParse" method works well

maxmarchuk commented 5 months ago

what does your tsconfig.json look like? I noticed my schemas were doing the same if either compilerOptions contains "strict": true or no strict property, or also if "strictNullChecks": false was set.

3fatty commented 5 months ago

what does your tsconfig.json look like? I noticed my schemas were doing the same if either compilerOptions contains "strict": true or no strict property, or also if "strictNullChecks": false was set.

ah, you'r right 👍 I didn't realize that sorry and thank you