Skip to content

fix route hooks typings#4628

Closed
aradwann wants to merge 3 commits intofastify:mainfrom
aradwann:fix-route-hooks-typings
Closed

fix route hooks typings#4628
aradwann wants to merge 3 commits intofastify:mainfrom
aradwann:fix-route-hooks-typings

Conversation

@aradwann
Copy link
Contributor

Checklist

fixes #4376 and #4595

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.

The types are still incorrect.

The hook system support either the use of promises or callbacks, but not both at the same time:

async (req, reply) => {}

or

`(req, reply. done) => {}

@Eomm Eomm added bugfix Issue or PR that should land as semver patch typescript TypeScript related labels Mar 14, 2023
@github-actions github-actions bot removed the typescript TypeScript related label Mar 24, 2023
method: 'GET',
url: '/',
handler: () => { },
onRequest: async (request, reply, done) => {
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect. When async is specified there should be no done callback.

Copy link
Contributor

Choose a reason for hiding this comment

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

Jees, why is the guy adding done or error payload in the code even when they are not being used in the function body?

If possible, can I correct this one?

Copy link
Member

Choose a reason for hiding this comment

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

Sure thing, send a fresh PR.

@Fdawgs Fdawgs added the typescript TypeScript related label Mar 30, 2023
@aradwann aradwann closed this Apr 2, 2023
@aradwann aradwann deleted the fix-route-hooks-typings branch April 2, 2023 09:36
JbIPS added a commit to JbIPS/fastify that referenced this pull request Apr 3, 2023
JbIPS added a commit to JbIPS/fastify that referenced this pull request Apr 5, 2023
@github-actions
Copy link

github-actions bot commented Apr 5, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix Issue or PR that should land as semver patch typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong typings for hooks on route options

5 participants