TCMiranda/joi-extract-type

Namespace 'Joi' has no exported member 'extractType'.

Closed this issue · 2 comments

Dependencies versions

@types/hapi__hapi: 19.0.3"
@types/hapi__joi: 17.1.4
joi-extract-type: "15.0.8"
typescript: "3.9.6"

Usage example

import Hapi from '@hapi/hapi'
import * as Joi from '@hapi/joi'
import 'joi-extract-type'


const registerValidator = Joi.object({
  name: Joi.string().required(),
  email: Joi.string().email().required(),
  social: Joi.object({
    facebook: Joi.string().optional(),
    twitter: Joi.string().optional(),
    github: Joi.string().optional(),
    website: Joi.string().optional(),
  }).optional(),

type RegisterInput = Joi.extractType<typeof registerValidator>;

server.route([
      {
        method: 'POST',
        path: '/register',
        handler: registerHandler,
        options: {
          auth: false,
          validate: {
            payload: registerValidator,
            failAction: 'error',
          },
        },
      },
    ])

However, I'm getting the following error when trying to compile:

error TS2694: Namespace 'Joi' has no exported member 'extractType'.

42 type RegisterInput = Joi.extractType<typeof registerValidator>;
                            ~~~~~~~~~~~

Any reason why module augmentation isn't working?

Hi @2color, unfortunately, we don't have integration with Joi >= 16, which I believe is the source of your error.
You can follow up or help with this issue here: #22

Thank you

@TCMiranda This should be clearly shown in README, to avoid this kind of unnecesary errors