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
Description
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
Labels
No labels