I have a node.js app and am using typescript with express in it. I have declared a error middleware function using
app.use((error:any, req:Request, res:Response, next:NextFunction) => {
res.status(500).json({message:error.message, stack:error.stack, path:req.path});
});
However I get errors about all the data types of the 4 inputs.
No overload matches this call.
The last overload gave the following error.
Argument of type '(error: any, req: Request, res: Response, next: NextFunction) => void' is not assignable to parameter of type 'PathParams'.ts(2769)
index.d.ts(163, 5): The last overload is declared here.
How can I fix this?
CodePudding user response:
Be sure that you imported the right classess from Express
import express, { Request, Response, Express, NextFunction } from "express";