New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types: Use full pino API as Logger default #5397
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Matthew Pietz <89040187+matt-smarsh@users.noreply.github.com>
It's like changing the default is incompatible with the generic |
Oof, yeah. Just looking at |
I think the hook handlers can be simplified quite a bit by using export interface onRequestHookHandler<
Server extends FastifyInstance<any, any, any, any, any>,
> {
(
this: Server,
request: Server extends FastifyInstance<any, infer RawRequest, any, any, any> ? RawRequest : never,
reply: Server extends FastifyInstance<any, any, infer RawReply, any, any> ? RawReply : never,
done: HookHandlerDoneFunction
): void;
} Then using it would allow each hook to be simplified to: addHook<
Fn extends onRequestHookHandler<this> | onRequestAsyncHookHandler<this> = onRequestHookHandler<this>
>(
name: 'onRequest',
hook: Fn extends unknown ? Fn extends AsyncFunction ? onRequestAsyncHookHandler<this> : onRequestHookHandler<this> : Fn,
): this; I don't know if this will break other areas but it would seem to help with preserving any user-defined custom interfaces. D'oh, I can see now that while that works, the |
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
Fixes #5382