onSendHookHandler: no option for payload type
- Dominant language
- No language data
- Stars
- 68
- Forks
- 8
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 2
Description
When implementing a function for onSend hook - there is no option to pass a type for onSendHookHandler and it's assuming that the payload is of `unknown` type
```js
// this code is not working:
export const myHook = (): onSendHookHandler => {
return async (req: FastifyRequest, rep: FastifyReply, payload: string) => {
....
}
}
// this code is working:
export const myHook = (): onSendHookHandler => {
return async (req: FastifyRequest, rep: FastifyReply, payload: unknown) => {
....
}
}
````
If onSendHookHandler supports generics - why we can't use it when declaring onSend:
```
onSend?: onSendHookHandler | onSendHookHandler[];
```
## Your Environment
- *node version*: 14
- *fastify version*: >=3.22.0
- *os*: Macx
Contributor guide
Assessment
This issue has not been assessed yet.