-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Description
Lines such as this in the zod codebase result in mutation of the passed context object.
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" as const }) : { direction: "backward" as const };
This causes weird issues if the same context object is used in multiple calls.
E.g.
const myOptions = { reportInput: true } as const;
z.decode(stringToDateCodec, someDateString, myOptions);
z.decode(stringToDateCodec, someOtherDateString, myOptions);
In my particular case it was causing a later decode call to run in reverse which passed a string to the encode function instead of a date.
The reason I am sharing an options object is because i'm trying to mimic global reportInput: true by simply passing it explicity in each call.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels