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

preHandler option is incorrectly typed #319

Closed
2 tasks done
Ethan-Arrowood opened this issue Aug 22, 2023 · 6 comments
Closed
2 tasks done

preHandler option is incorrectly typed #319

Ethan-Arrowood opened this issue Aug 22, 2023 · 6 comments

Comments

@Ethan-Arrowood
Copy link
Member

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.21.0

Plugin version

9.2.1

Node.js version

20.x

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

NA

Description

The type for the preHandler (and assumingly the beforeHandler) options are slightly incorrect as they do not correctly infer support for async:

await app.register(import('fastify-http-proxy'), {
  preHandler: async (request, reply) { },
  ...
};

TypeScript doesn't fail because I believe the current type satisfies the async version, but when you have ESLint enabled, ESLint complains that you are returning a promise where void is expected.

We need to use the preHandlerAsyncHookHandler i think. I'll send a fix soon.

Steps to Reproduce

na

Expected Behavior

na

@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 22, 2023

Maybe has to be typed like I did in the changes in hooks.d.ts (unreleased afaik)

@Ethan-Arrowood
Copy link
Member Author

Probably. Is that something unreleased for this module? Or somewhere else?

@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 22, 2023

This:

fastify/fastify#4945

@Ethan-Arrowood
Copy link
Member Author

Ahh so if that is published, then the existing type will work?

@Ethan-Arrowood
Copy link
Member Author

I guess after this module is updated to the new version of Fastify too

@mcollina
Copy link
Member

mcollina commented Sep 6, 2023

@Ethan-Arrowood this should be done now

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

No branches or pull requests

3 participants