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
I want to use a branded type in a function's args.
Example:
constTest=z.function().args(z.string().brand('BrandedString'),z.string()).returns(z.void());typeTest=z.infer<typeoftest>;// -> (args_0: string, args_1: string, ...args: unknown[]) => void// But Zod should interpret this type as follows// -> (args_0: string & z.BRAND<"BrandedString">, args_1: string, ...args: unknown[]) => void
In the following code, I am encountering the error
constBranded=z.string().brand('BrandedString')typeBranded=z.infer<typeofBranded>;constTest=z.function().args(Branded,z.string()).returns(z.void());typeTest=z.infer<typeoftest>;constfuncs: {sample: Test}={sample: (a: Branded,b: string)=>{}^^^^^^}// -> Type '(a: Branded, b: string) => void' is not assignable to type '(args_0: string, args_1: string, ...args: unknown[]) => void'.// -> ...Type 'string' is not assignable to type 'BRAND<"BrandedString">' ts(2322)
I want to be fixed this bug, but if there is a reason for this spec, I would like to know why and what the best practice is.
The text was updated successfully, but these errors were encountered:
I want to use a branded type in a function's args.
Example:
In the following code, I am encountering the error
I want to be fixed this bug, but if there is a reason for this spec, I would like to know why and what the best practice is.
The text was updated successfully, but these errors were encountered: