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
We have a field that has a type of bigint with min/max. But the output doesn't produce a correct schema.
Input
/** * @minimum -999999999 scale must be greater than or equal to -999999999 * @maximum 999999999 scale must be less than or equal to 999999999 */typeFoo={scale: bigint}
Expected output
constfooSchema=z.object({scale: z.bigint().min(BigInt(-999999999),'scale must be greater than or equal to -999999999').max(BigInt(999999999),'scale must be less than or equal to 999999999'),})
Actual output
constfooSchema=z.object({scale: z.bigint().min(-999999999,'scale must be greater than or equal to -999999999').max(999999999,'scale must be less than or equal to 999999999'),})
This is also a Typescript error
Versions
Typescript: ^5.5.4
Zod: ^3.23.8
ts-to-zod: '^3.13.0'
The text was updated successfully, but these errors were encountered:
/**
* @minimum BigInt(-999999999) scale must be greater than or equal to -999999999
* @maximum BigInt999999999) scale must be less than or equal to 999999999
*/
Indeed, the bigInt type it not detected.
Not an easy fix given the way JSDoc tags are handled (they're unaware of the underlying property)
A workaround can be implemented using the @schema annotation:
typeFoo={/** * @schema .min(BigInt(-999999999), "scale must be greater than or equal to -999999999").max(BigInt(999999999), "scale must be less than or equal to 999999999") */scale: bigint;};
This will append whatever is behind the @schema at generation time:
// Generated by ts-to-zodimport{z}from"zod";constfooSchema=z.object({scale: z.bigint().min(BigInt(-999999999),"scale must be greater than or equal to -999999999").max(BigInt(999999999),"scale must be less than or equal to 999999999"),});
Bug description
We have a field that has a type of
bigint
with min/max. But the output doesn't produce a correct schema.Input
Expected output
Actual output
This is also a Typescript error
Versions
^5.5.4
^3.23.8
The text was updated successfully, but these errors were encountered: