hapijs / hapijs/joi

Incorrect type of Joi.Extension.args property

Open
#2,511 1 comment 0 reactions 0 assignees View on GitHub
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?* no
* *is this issue affecting a production system?* no

#### Context

* *node version*: v14.15.0
* *module version with issue*: 17.3.0
* *last module version without issue*: Didn't check, bug is probably since the release of this feature
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone
* *any other relevant information*: I am using the types of this module, so not the types of Definitely Typed (which are using the same types for this particular problem)

#### What are you trying to achieve or the steps to reproduce?

As stated in the release notes of [v16](https://github.com/sideway/joi/issues/2037) (and mentioned in [issue 1932](https://github.com/sideway/joi/issues/1932)), the `args` property of an extension allows to use parameters in custom extensions. The following code is provided as an example:

```js
const custom = Joi.extend({
type: 'special',
base: Joi.string(),
args(schema, limit) {
return schema.min(limit); // schema has wrong type
}
});

const schema = custom.special(2);
```

The code works but the type of `Joi.Extension.args` is incorrect. (I have no clue what the correct type should be either). A workaround is to disable type checking.

#### What was the result you got?
The TypeScript type of the `Joi.Extension.args` property is incorrect.

#### What result did you expect?
The TypeScript type of the `Joi.Extension.args` property is correct.

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.