Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

TypeScript - merge declarations for request and response types #789

Open
U-4-E-A opened this issue Nov 16, 2021 · 0 comments
Open

TypeScript - merge declarations for request and response types #789

U-4-E-A opened this issue Nov 16, 2021 · 0 comments

Comments

@U-4-E-A
Copy link

U-4-E-A commented Nov 16, 2021

app.use(
    '/graphql',
    expressGraphQL((req, res) => ({
        schema,
        context: {
            req,
            res,
            currentUser: req.user,
            db,
            confirmCurrentUser: (): void => {
                if (typeof req.user === 'undefined') {
                res.status(401)
         }
      }
    },
  })
)

I get TS errors for req.user ("Property 'user' does not exist on type 'IncomingMessage'.ts(2339)") and res.status ("Property 'status' does not exist on type 'ServerResponse'.ts(2339)"). Is there a guide on how to merge declarations to add custom properties? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant