You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zodv4 output produces unknown for optional nested input fields with exactOptionalPropertyTypes: true #1494
(Note this is an AI-generated summary from troubleshooting session).
I’m seeing a TypeScript assignability error in generated zod.ts when using graphql-codegen-typescript-validation-schema with:
schema: 'zodv4'
imported generated types via importFrom
TypeScript exactOptionalPropertyTypes: true
In this setup, nested optional input fields can be emitted with unknown in Zod output typing, which then fails assignment to the generated GraphQL input types.
Possibly related to #1460 (similar need for manual type correction), but this report is specifically about zodv4 + exactOptionalPropertyTypes: true producing unknown in nested optional input output types.
Type '{ ... customizable_options?: unknown; ... } | null' is not assignable to type 'InputMaybe<BundleProductCartItemInput>'.
Types of property 'customizable_options' are incompatible.
Type 'unknown' is not assignable to type 'InputMaybe<InputMaybe<CustomizableOptionInput>[]>'.
Expected behaviour
Generated Zod schemas should typecheck with exactOptionalPropertyTypes: true, without degrading nested optional field types to unknown.
Additional notes
inputMaybeValue: 'T | null | undefined' is already set on TypeScript generation.
The issue appears specific to the zodv4 emitter path.
Behaviour is reproducible on nested optional input arrays/objects.
Workaround
Switch the validation schema emitter to zod while keeping Zod v4 runtime import:
Activity