Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ExternalValidationFunction" type is missing "helpers" parameter in index.d.ts #2605

Closed
bromy opened this issue May 5, 2021 · 0 comments · Fixed by #2665
Closed

"ExternalValidationFunction" type is missing "helpers" parameter in index.d.ts #2605

bromy opened this issue May 5, 2021 · 0 comments · Fixed by #2665
Labels
bug Bug or defect types TypeScript type definitions
Milestone

Comments

@bromy
Copy link
Contributor

bromy commented May 5, 2021

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 14.16.0
  • module version with issue: 17.4.0
  • last module version without issue:
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): typescript
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

// using an external method in a TypeScript project
const isValidUser = async (value: any, helpers: any): Promise<any> { ... }
const userSchema = Joi.string().external(isValidUser)

What was the result you got?

Argument of type '(value: any, helpers: any) => Promise<any>' is not assignable to parameter of type 'ExternalValidationFunction'.

What result did you expect?

The ExternalValidationFunction type supports the helpers parameter as indicated in the documentation, even when used with TypeScript. At the least, the typing should probably be:

type ExternalValidationFunction = (value: any, helpers: any) => Promise<any>;
@hueniverse hueniverse added the types TypeScript type definitions label May 7, 2021
@hueniverse hueniverse added this to the 17.5.0 milestone Dec 1, 2021
@hueniverse hueniverse added the bug Bug or defect label Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect types TypeScript type definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants