Skip to content

Incorrect types for joi.expression and LanguageMessages #3064

Open
@davidjamesstone

Description

@davidjamesstone

Module version

17.13.3

What documentation problem did you notice?

joi.expression type documentation

According to the docs, the second optional argument options is the same as the options for joi.ref with an additional functions object. This isn't reflected in the .d.ts file here.

I think it should be something like:

expression(template: string, options?: ReferenceOptions & { functions: Record<string, function>})

LanguageMessages type documentation

LanguageMessages is typed as type LanguageMessages = Record<string, string | Record<string, string>>; but the record value could also be a joi.expression(), correct?

I'm using Joi like this below and it seems to be happy, although the types aren't.

import lowerFirst from 'lodash/lowerFirst.js'

export const messages: LanguageMessages = {
  'string.base': joi.expression('Enter {{lowerFirst(#label)}}', { functions: { lowerFirst }})
}

Before I submit a PR, do you agree the types are incorrect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions