Missing Return Type ErrorReport[] for any.error ValidationErrorFunction
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used [patch-package](https://github.com/ds300/patch-package) to patch `joi@17.6.0` for the project I'm working on.
It seems that the type definition for return type of any.error which is a function of type `ValidationErrorFunction` does not have the proper return signature. As per documentation:

The ValidationErrorFunction should return either a single Error or an array of validation reports but it seems like it does not. I have added ErrorReport[] as another of the possible return types. This should probably be fixed if this issue is legitimate.
Here is the diff that solved my problem:
```diff
diff --git a/node_modules/joi/lib/index.d.ts b/node_modules/joi/lib/index.d.ts
index d6218c6..350a8c9 100644
--- a/node_modules/joi/lib/index.d.ts
+++ b/node_modules/joi/lib/index.d.ts
@@ -659,7 +659,7 @@ declare namespace Joi {
context?: Context;
}
- type ValidationErrorFunction = (errors: ErrorReport[]) => string | ValidationErrorItem | Error;
+ type ValidationErrorFunction = (errors: ErrorReport[]) => string | ValidationErrorItem | Error | ErrorReport[];
type ValidationResult = {
error: undefined;
```
This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).
Contributor guide
Assessment
This issue has not been assessed yet.