How to fix Namespace 'Joi' has no exported member 'extractType'

Viewed 745

I am extracting type from Joi schema using joi-extract-type. It has no compile time issue with @hapi/joi but when upgraded Joi to latest version of now (17.2.1). It does not understand extractType.

What could be simplest solution to get it fixed until it's typing is fixed at source?

One solution could be, providing this typing locally. Could anybody provide declaration for this or any other better solution?

export type dto = Joi.extractType<typeof schema>;

"joi": "^17.2.1",
"joi-extract-type": "^15.0.8",
1 Answers

In express-joi-validation documantation you will find this note above 'joi-extract-type' exemple. NOTE: this does not work with Joi v16+ at the moment. Link for the issue.

If you want to use 'joi-extract-type' you must downgrade 'joi' below v16.

Related