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

Typescript types missing for FastifyRequest and RouteShorthandOptions when using the transact route option #141

Closed
2 tasks done
bdun94 opened this issue Aug 12, 2022 · 1 comment · Fixed by #142
Closed
2 tasks done

Comments

@bdun94
Copy link
Contributor

bdun94 commented Aug 12, 2022

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.0.0

Plugin version

5.0.0

Node.js version

16.16.0

Operating system

macOS

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

12.4

Description

When attempting to use the transact route option using typescript, passing in the transact route options and referencing pg from the request object throws typescript type errors. This is because because pg has not been added to FastifyRequest and

interface FastifyPostgresRouteOptions {
  transact: boolean | string;
}

has not been added for pg for RouteShorthandOptions

Steps to Reproduce

fastify.post(
    '/',
    {
      pg: { transact: true }, // Throws type error for RouteShorthandOptions
    },
    async (req, _reply) => {
      req.pg.query('SELECT * FROM table') // Throws type error for FastifyRequest
    }
  );

Expected Behavior

Using the route transact option should not cause compile errors in typescript

@bdun94
Copy link
Contributor Author

bdun94 commented Aug 12, 2022

Sorry for the accidental close, wanted to comment that I've added a PR for this since it seems easy enough to resolve. Let me know if there's anything else I need to do or if there's an issue with this PR

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 a pull request may close this issue.

1 participant