Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
This repository was 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

Description

@U-4-E-A
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions