hapijs / hapijs/joi

Add typings to `.extend()`

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

Description

#### Context

* *node version*: 16.13.0
* *module version*: 17.5.0
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone
* *any other relevant information*:

#### What problem are you trying to solve?

Currently [`.extend()` is typed to return `any`](https://github.com/sideway/joi/blob/2cde8a3656498753b42ec22d1bf7f871959488a3/lib/index.d.ts#L2120). This completely removes all typing functions (even the base package typings) whenever Joi is extended.

```js
const Joi = require("joi").extend('@joi/date')

// Joi is now an `any` with no typings whatsoever.
```

#### Do you have a new or modified API suggestion to solve the problem?

No- I'm not good enough with typescript to figure this one out. I tried tweaking the return type from `any` to`Joi`, but this doesn't seem to work - probably something to do with `Joi` being a namespace, not a class.

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.