Closed adamayres closed 1 month ago
Thanks for the great lib! I noticed that the compiled types for actions lose the typing for the requirement in the function callback format of ErrorMessage.
requirement
ErrorMessage
Repro:
https://stackblitz.com/edit/typescript-4u6iog?file=index.ts
For example, the compiled type of minLength is:
minLength
declare function minLength<TInput extends string | any[], TRequirement extends number>(requirement: TRequirement, message?: ErrorMessage): MinLengthValidation<TInput, TRequirement>;
Note the typing on ErrorMessage lost it's generic parameters.
In the source code this type appears to be properly passed.
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/actions/minLength/minLength.ts#L90-L99
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/types/other.ts#L22-L24
BaseIssue
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/types/issue.ts#L55-L83
This should be fixed in the RC we released last week. Have a look at this playground.
Thanks for the quick response, looks good in the RC.
Thanks for the great lib! I noticed that the compiled types for actions lose the typing for the
requirement
in the function callback format ofErrorMessage
.Repro:
https://stackblitz.com/edit/typescript-4u6iog?file=index.ts
For example, the compiled type of
minLength
is:Note the typing on
ErrorMessage
lost it's generic parameters.In the source code this type appears to be properly passed.
minLength
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/actions/minLength/minLength.ts#L90-L99
ErrorMessage
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/types/other.ts#L22-L24
BaseIssue
https://github.com/fabian-hiller/valibot/blob/2bdb2c8cb2228cc9d11776a60ba7e380caaece97/library/src/types/issue.ts#L55-L83