Skip to content
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

Fix typings for http methods shortcuts on fastify reply #134

Merged
merged 1 commit into from
May 3, 2023
Merged

Fix typings for http methods shortcuts on fastify reply #134

merged 1 commit into from
May 3, 2023

Conversation

g0di
Copy link
Contributor

@g0di g0di commented Apr 24, 2023

Fix typings for HTTP methods shortcuts added on the FastifyReply object.

Those signatures were indicating a void return while the implementations were returning the reply itself.

fixes #133).

I've only updated the typings tests accordingly because the implementation tests were already ensuring that those shortcuts were returning the fastify reply object.

Also note that I've moved the following type from httpError.d.ts to index.d.ts

type HttpErrorReplys = {
  getHttpError: (code: HttpErrorCodes, message?: string) => FastifyReply;
} & Record<HttpErrorNames, (msg?: string) => FastifyReply>;

The reason is that I think the lib folder may not contain code related to fastify itself. It made more sense to me to put that type as close as possible to the concerned FastifyReply interface.

Checklist

  • run npm run test and npm run benchmark (there is no benchmark script)
  • tests and/or benchmarks are included
  • documentation is changed or added (no need to update the doc)
  • commit message and code follows the Developer's Certification of Origin
    and the Code of conduct

Those functions definitions were indicating a return void while the implementation was actually returning the fastify reply
@g0di g0di mentioned this pull request Apr 24, 2023
2 tasks
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 8073ee0 into fastify:master May 3, 2023
@g0di g0di deleted the shortcuts-typings branch May 3, 2023 09:27
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fastify reply functions wrongly typed
2 participants