If I remove the void from the response (Response | void) this gives me an error, but I can't put return next () either
public async verifyUser(req: Request, res: Response, next: NextFunction): Promise<Response | void> {
try {
// do all ...
next();
} catch (e) {
return HttpHandler.response(res, 500, { message: e.message });
}
}
HttpHandler Class
import { Response } from 'express';
class HttpHandler {
/**
*
* @param res
* @param status
* @param message
* @param data
* @returns
*/
public response(res: Response, status: number, data = {}): Response {
return res.status(status).json({ result: data });
}
}
export default new HttpHandler();
Error: Function lacks ending return statement and return type does not include 'undefined'.ts(2366)