hapijs / hapijs/joi

ObjectSchema.describe() has incorrect typing

Open
#2,847 2 comments 0 reactions 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
21.2k
Forks
1.5k
Avg merge
4h 57m
Merged PRs (30d)
14

Description

#### 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:

```ts
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](https://github.com/hapijs/joi/blob/d7afcd567bab64a79a4d38332c5b169c5f0e3bf6/lib/index.d.ts#L1264).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.