Using .transform()
stops z.discriminatedUnion
from working
#2315
Labels
stale
No activity in last 60 days
.transform()
stops z.discriminatedUnion
from working
#2315
Hi there,
May I please have some help I am stuck with an issue which seems to be caused by
SomeZodType.transform(fn=>...)
whenfn
returns a type which is incompatible with the originalSomeZodType
. Whenever I use.transform()
the types will no longer work inz.discriminatedUnion
.Is this intended behavior, or am I missing something?
Please excuse the really long example code below;
At this point I am stuck because
Entity
is part of a library; user code is supposed to implement arbitrary Component types and give each implementation its ownstatic schema=...
, therefore I can't giveEntity.components
static schema inside the Entity classcomponents = [Velocity.schema, Position.schema]
Entity.register_components(components)
z.discriminatedUnion("type", components)
Whenever I try to make a function that passes a list of component schemas into
z.discriminatedUnion
I get a massive error which is hard to understand;I tried my best to find any existing issues or questions... this one looks related? #2146 . There was a suggestion in that thread to try zod@canary, but that doesn't seem to have helped.
The text was updated successfully, but these errors were encountered: