joi
joi copied to clipboard
fix(typings): incompatible type issue for nested strict object schemas
The type issue that prevented strict object schemas from being nested has been resolved. The following is no longer incorrectly flagged as an error.
interface ObjType {
firstName: string;
lastName: string;
nestedObject: {
middleName: string;
}
}
// no errors
Joi.object<ObjType, true>({
firstName: Joi.string(),
lastName: Joi.string(),
nestedObject: Joi.object<ObjType['nestedObject'], true>({
middleName: Joi.string()
})
})
This PR fixes #2764.
@LeoAso What is the state of this? We are heavily relying on this and have a lot of workarounds we'd like to get rid of :)
@phillip-kil It seems the maintainers haven't gotten around to reviewing it yet.
This looks fine, although, would you mind adding tests in this file to avoid any further regression?
Superseded by #2836, thanks for doing the initial work though!