Closed lucalabs-de closed 1 year ago
Hi, I will check this PR but I'm not a TS user so it takes me more time. As note, I will be "inspired" coping from other fastify plugins (since there are very strong people on TS there 😄 )
For example the fastify-sensible
plugin add a request.vary
function
https://github.com/fastify/fastify-sensible/blob/master/index.d.ts
So I think we could do as it does
Closing due missing tests
Here is an example of workable PR to add types: https://github.com/Eomm/fastify-overview/pull/61
I added the necessary type definitions to import and register the plugin in typescript, the dynamic decoration of the FastifyRequest type is problematic though. I have no idea if that is even possible to type in a
.d.ts
file. That means that the typescript parser throws an error when trying to access FastifyRequest.rawBody.A possible workaround for this is to define the type in the application using this plugin.