fix(@hapi/joi): fix extend typings (#42297)

This commit is contained in:
Simon Schick
2020-02-14 09:24:00 -08:00
committed by GitHub
parent 186ed7ba26
commit 058b3a2fca
2 changed files with 19 additions and 5 deletions

View File

@@ -1012,11 +1012,18 @@ const Joi3 = Joi.extend({
asd: {
args: [
{
name: 'allowFalse'
name: 'allowFalse',
ref: true,
assert: Joi.boolean(),
}
],
method(allowFalse) {
this.$_createError(str, {}, {}, {}, {});
method(allowFalse: boolean) {
return this.$_addRule({
name: 'asd',
args: {
allowFalse,
}
});
},
validate(value: boolean, helpers, params, options) {
if (value || params.allowFalse && !value) {

View File

@@ -679,6 +679,13 @@ declare namespace Joi {
type SchemaFunction = (schema: Schema) => Schema;
interface AddRuleOptions {
name: string;
args?: {
[key: string]: any;
};
}
interface SchemaInternals {
/**
* Parent schema object.
@@ -693,7 +700,7 @@ declare namespace Joi {
/**
* Adds a rule to current validation schema.
*/
$_addRule(rule: string | ExtensionRule): Schema;
$_addRule(rule: string | AddRuleOptions): Schema;
/**
* Internally compiles schema.
@@ -1756,7 +1763,7 @@ declare namespace Joi {
interface RuleArgs {
name: string;
ref?: boolean;
assert?: (value: any) => boolean;
assert?: ((value: any) => boolean) | AnySchema;
message?: string;
/**