TCMiranda / joi-extract-type

Provides native type extraction from Joi schemas for Typescript
MIT License
151 stars 27 forks source link

Improper typing when Joi.any().required() #31

Closed lonewarrior556 closed 4 years ago

lonewarrior556 commented 4 years ago

Simple example

This is correct

let schema = Joi.object({
  a: Joi.any(),
})

type A = Joi.extractType<typeof schema>;
// type A is  { a?: any; }

this is wrong

let schema = Joi.object({
  a: Joi.any().required(),
})

type A = Joi.extractType<typeof schema>;
// type A still is { a?: any; } but should be { a: any }