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
type the_filterTypes = z.infer<typeof filterTypes>;
is inferred as
type the_filterTypes = {
[x: string]: any;
type?: unknown;
}
instead of the discriminated union type.
i already searched for similar questions, but i only found questions about "recursive" types or only about the discriminatedUnion, not both together. according to docs there needs to be a type-hint provided for "recursive" but i do not know how this is supposed to be provided if the "type-hint" itself needs to contains the "condition" field, which is supposed to be of type of the final schema.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
i am trying to implement the following type in zod:
this is a simplified version of the real type.
i tried the following:
but this is wrong, because
type the_filterTypes = z.infer<typeof filterTypes>;
is inferred as
instead of the discriminated union type.
i already searched for similar questions, but i only found questions about "recursive" types or only about the discriminatedUnion, not both together. according to docs there needs to be a type-hint provided for "recursive" but i do not know how this is supposed to be provided if the "type-hint" itself needs to contains the "condition" field, which is supposed to be of type of the final schema.
any help would be really appreciated.
Beta Was this translation helpful? Give feedback.
All reactions