strictNullChecks=false makes z.object() properties optional #2160
Answered
by
JacobWeisenburger
AndrewSmir
asked this question in
Q&A
-
Hi! Turning off strictNullChecks in compilerOptions makes all object properties optional. tsc -v: 4.9.5 tsconfig: {
"compilerOptions": {
"strictNullChecks": false,
"strict": true,
}
} Example: const Dog = z.object({
name: z.string(),
age: z.number(),
});
type Dog = z.infer<typeof Dog>; Expected result: type Dog = {
name: string;
age: number;
}; Actual result: type Dog = {
name?: string;
age?: number;
}; |
Beta Was this translation helpful? Give feedback.
Answered by
JacobWeisenburger
Mar 7, 2023
Replies: 1 comment
-
https://github.com/colinhacks/zod#requirements
if you disable |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
JacobWeisenburger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/colinhacks/zod#requirements
if you disable
strictNullChecks
, then you are disabling part ofstrict
mode which is required for zod to work correctly.