joi icon indicating copy to clipboard operation
joi copied to clipboard

fix(typings): incompatible type issue for nested strict object schemas

Open LeoAso opened this issue 2 years ago • 2 comments

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 avatar May 21 '22 09:05 LeoAso

@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 avatar Jul 25 '22 12:07 phillip-kil

@phillip-kil It seems the maintainers haven't gotten around to reviewing it yet.

LeoAso avatar Aug 03 '22 08:08 LeoAso

This looks fine, although, would you mind adding tests in this file to avoid any further regression?

Marsup avatar Aug 20 '22 17:08 Marsup

Superseded by #2836, thanks for doing the initial work though!

Marsup avatar Sep 17 '22 16:09 Marsup