hapijs / hapi

The Simple, Secure Framework Developers Trust
https://hapi.dev
Other
14.61k stars 1.34k forks source link

Build issues #4491

Open JimmyBjorklund opened 6 months ago

JimmyBjorklund commented 6 months ago

Runtime

nodejs

Runtime version

v20.10.0

Module version

v20.10.0

Last module version without issue

No response

Used with

tsoa

Any other relevant information

tsc

node_modules/@hapi/hapi/lib/types/route.d.ts:2:68 - error TS2307: Cannot find module 'joi' or its corresponding type declarations.

2 import { ObjectSchema, ValidationOptions, SchemaMap, Schema } from 'joi';


node_modules/@hapi/hapi/lib/types/server/server.d.ts:4:22 - error TS2307: Cannot find module 'joi' or its corresponding type declarations.

4 import { Root } from 'joi';

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

create any packet.json and have skipLibCheck = true

What was the result you got?

node_modules/@hapi/hapi/lib/types/route.d.ts:2:68 - error TS2307: Cannot find module 'joi' or its corresponding type declarations.

2 import { ObjectSchema, ValidationOptions, SchemaMap, Schema } from 'joi';


node_modules/@hapi/hapi/lib/types/server/server.d.ts:4:22 - error TS2307: Cannot find module 'joi' or its corresponding type declarations.

4 import { Root } from 'joi';

What result did you expect?

No error

kanongil commented 6 months ago

Yeah, the hapi types require the Joi typings to compile. This is not ideal, but how it is currently. I'm sure a PR that decouples it would be very welcome.

You should be able to fix it by installing the joi module as a development dependency.

Are you sure it's not activated by skipLibCheck = false?

JimmyBjorklund commented 6 months ago

If joi is required its not a dev dependency, looking in you packet.json its listed as a dev dependency. adding it to the project using npm install joi removes the error but this is a hack as i see it.

kanongil commented 6 months ago

Joi is only required for compiling the typescript types, so it won't be added as a normal dependency. This is similar to the typescript dev dependency.

This is indeed a hack, because there is no decent solution until someone takes the time to decouple it in the hapi typings. Again a PR would be welcome.