I've noticed that the types for @hapi/joi
appear to be outdated - some configuration parameters mentioned in the official documentation are missing from the types. To address this, I am attempting to enhance the existing types.
node_modules/@types/hapi__joi/index.d.ts:
declare namespace Joi {
...
interface ErrorFormattingOptions {...}
...
interface Root {...}
}
declare const Joi: Joi.Root;
export = Joi;
In one of my .ts source files:
import joi from '@hapi/joi'
declare global {
namespace Joi {
interface ErrorFormattingOptions {
wrap?: {
label?: string | false
array?: string | false
}
}
}
}
However, it seems that this approach is not working as expected.
type R = Joi.ErrorFormattingOptions['']//autocomplete show only my 'wrap'
What is the correct method to augment the types in this scenario? Thank you.
UPDATE: It appears that achieving this augmentation may not be feasible. The module '@hapi/joi'
does not have a named export ErrorFormattingOptions
. Unfortunately, TypeScript does not allow augmentation of entities that are not exported.