Closed johnboulder closed 2 years ago
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
I tried to reproduce this by adding some tests to the type definitions at #174. The existing declarations seems to work just fine. The test suit uses:
"@types/hapi__hapi": "^20.0.10",
I could very well be wrong on this, but it seems like the module augmentation done on the Request object is not implemented properly.
I found myself on a journey learning about Module Augmentation recently that was sparked by what you guys are doing in this project. I noticed when trying to use the
logger
decorator in hapi plugins written in typescript, my IDE was failing to recognize the property was added on theRequest
object.Through testing, I found that the logger worked as expected, so this just meant that there was something wrong with the type resolution.
While working with writing my own decorators in typescript, and making sure the Module Augmentation got picked up correctly, I stumbled across this on stack overflow, and realized why the augmented type wasn't being resolved when I tried to use the one declared here in hapi-pino. So I figured I'd share!
Also, I never used the
server.logger
, decorator, but for all I know it could be in the same boat.TLDR
The module augmentation on the Request object, declared in this project's types, needs to be adjusted in order for it to be resolved correctly in typescript projects.
This
Should look like this