Hey guys,
I have a very odd problem with some code that I have written. It is some Express middleware to be used to make my life easier when working with lots of different API routes etc.
This code does not differ from the previous codebase for this project, but for some reason I am getting errors this time around, and I am honestly clueless as to why.
Here is the error in question:
TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type
(req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>
is not assignable to parameter of type
RequestHandlerParams<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
Type '(req: Request, res: Response, next: NextFunction) => void | Response<any, Record<string, any>>' is not assignable to type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.
Type void | Response<any, Record<string, any>> is not assignable to type void | Promise<void>
Type Response<any, Record<string, any>> is not assignable to type void | Promise<void>
Now, this error looks pretty self explanatory, however in my middleware code I see no problems:
const User = (allowBanned = false) =>
(req: Request, res: Response, next: NextFunction) => {
// Main method logic, uses `return next();` and `return res.json` etc.
}
Additionally, I am also getting a weird error with Express features that I know damn well exist! Take this code for example:
import { Router } from "express";
const router = Router({
mergeParams: true, // This would normally not error, but it does..
});
The error in question states that the method expected 0 arguments but got 1. I am genuinely confused, as the Express API has not changed (I even installed the same version as what was used on the last codebase).
I would just really like help if anyone can provide it, thank you in advance.