joi
joi copied to clipboard
Typescript typing on `Joi.string().validate(...)`
Context
- node version: 14.17.X
- module version with issue: 17.5.0
- last module version without issue: 17.5.0
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
const schema = Joi.string();
const result = schema.validate(getUnknownValue());
if (!result.error) {
result.value; // typed as `any` but should be `string`
}
What was the result you got?
The result of Joi.string().validate(...)
has the field value
typed as any
.
What result did you expect?
The result of Joi.string().validate(...)
has the field value
typed as string
.
On a related note, it also seems strange that Joi.array()
only every validates to any
. Not even any[]
Yes please.
This seems to be fixed by #2860 🎉
Thanks for mentioning it @Nokel81, that's one less issue 😅