[@types/hapi__joi]: fix SchemaInternals.$_getRule return type (#45552)

* Adds GetRuleOptions type

* Fixes return type of SchemaInternal.$_getRule to return optional GetRuleOptions object, previously array
This commit is contained in:
notchairmk 2020-07-10 07:13:15 -07:00 committed by GitHub
parent 1fcf2f98a0
commit e39b0ad3bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -1159,6 +1159,13 @@ schema = Joi.symbol().map({
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
const rule = Joi.string().case('upper').$_getRule('case');
if (rule && rule.args) {
const direction = rule.args.direction;
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
schema = Joi.any();
const terms = schema.$_terms;

View File

@ -726,6 +726,13 @@ declare namespace Joi {
};
}
interface GetRuleOptions {
args?: Record<string, any>;
method?: string;
name: string;
operator?: string;
}
interface SchemaInternals {
/**
* Parent schema object.
@ -767,7 +774,7 @@ declare namespace Joi {
/**
* Retrieve some rule configuration.
*/
$_getRule(name: string): ExtensionRule;
$_getRule(name: string): GetRuleOptions | undefined;
$_mapLabels(path: string | string[]): string;