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
Using a zod enum in an object degenerates to generic string.
constMyEnumType=z.enum(['a','b']);typeMyEnum=z.infer<typeofMyEnumType>;typeMyObject={foo: MyEnum};functiontestFunc(){letx: MyObject={foo: 'a'};constparsed=MyEnumType.safeParse('a');if(parsed.success){lety={foo: parsed.data};x=y;// Type '{ foo: string; }' is not assignable to type 'MyObject'.}}
As a workaround, I can use z.union([z.literal('a'), z.literal('b')]), but the verbosity is inconvenient.
The text was updated successfully, but these errors were encountered:
Using a zod enum in an object degenerates to generic string.
As a workaround, I can use
z.union([z.literal('a'), z.literal('b')])
, but the verbosity is inconvenient.The text was updated successfully, but these errors were encountered: