Skip to content

type problem in Joi.isSchema function #2585

@dev-a-loper

Description

@dev-a-loper

Support plan

  • is this issue currently blocking your project? no
  • *is this issue affecting a production system?*no

Context

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

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

Joi.isSchema verifies that an object is joi schema or not, but in type definition it is not using type predicate to indicate the schema is of type joi schema when return value is true

function doSomeThingWithSchemaOrString(input:Joi.Schema|AnotherType){
    if(Joi.isSchema(input)){
        input.validate('a test validation input')
//           ^^ Error: Property 'validate' does not exist on type Joi.Schema | AnotherType
   }
}

What was the result you got?

typescript error

What result did you expect?

the code should compile successfully

Metadata

Metadata

Assignees

Labels

bugBug or defecttypesTypeScript type definitions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions