joi icon indicating copy to clipboard operation
joi copied to clipboard

ObjectSchema.describe() has incorrect typing

Open grundb opened this issue 1 year ago • 1 comments

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 18
  • module version with issue: 17.6.0
  • last module version without issue: don't know
  • environment (e.g. node, browser, native): ts-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?

I am trying to use the ObjectSchema.describe function in the way that the typings suggest I could.

The object returned by ObjectSchema.describe does not match it's corresponding type definition:

import joi from 'joi'; // 17.6.0
const myObj = joi.object({foo: joi.string().description('bar')});
myObj.describe();

What was the result you got?

{ type: 'object', keys: { foo: { type: 'string', flags: [Object] } } }

What result did you expect?

An object without the keys property, matching the Description type here.

grundb avatar Sep 25 '22 11:09 grundb