I am using hapi for one of my node+typescript project. I am trying to update hapi to the new @hapi/hapi package, due to the deprecation of the "naked" packages. I've changed @types/hapi to @types/hapi__hapi.
As soon as I updated, I started getting the TypeScript error -
node_modules/@types/hapi__hapi/index.d.ts:514:32 - error TS2709: Cannot use namespace 'Boom' as a type.
514 response: ResponseObject | Boom;
~~~~
node_modules/@types/hapi__hapi/index.d.ts:4050:18 - error TS2709: Cannot use namespace 'Boom' as a type.
4050 (Error | Boom) |
~~~~
Found 2 errors.
Here's the dependencies I have in package.json -
{
...
"devDependencies": {
...
"@types/hapi__boom": "7.4.1",
"@types/hapi__hapi": "18.2.5",
"@types/hapi__joi": "16.0.1",
"@types/nock": "10.0.3",
"@typescript-eslint/eslint-plugin": "2.4.0",
"jest": "24.9.0",
"nock": "11.4.0",
"nodemon": "1.19.4",
"prettier": "1.18.2",
"typescript": "3.6.4"
},
"dependencies": {
...
"@hapi/boom": "8.0.1",
"@hapi/hapi": "18.4.0",
"@hapi/joi": "16.1.7",
"axios": "0.19.0",
"axios-retry": "3.1.2"
},
...
}
I checked the node_modules/@types/hapi__hapi/index.d.ts file and it was importing Boom using the following way -
import * as Boom from '@hapi/boom';
When I change it to
import { Boom } from '@hapi/boom';
and it solved the error.
I can't change the index.d.ts file, as it's from @types/hapi__hapi package, but I want to solve this issue. Is there anything I can do to not have this error, such as downgrading to some specific version?