Мой маршрутизатор: < /p>
Код: Выделить всё
import { Router } from "express";
import { register } from "../controllers/auth";
const authRouter = Router();
authRouter.post("/register", register);
export default authRouter;
< /code>
Ошибка: < /p>
No overload matches this call.
The last overload gave the following error.
Argument of type '(req: Request
>, res: Response, next: NextFunction) => Promise' is not assignable to parameter of type 'Application'.
Type '(req: Request, res: Response, next: NextFunction) => Promise' is missing the following properties from type 'Application': init, defaultConfiguration, engine, set, and 63 more.ts(2769)
index.d.ts(168, 5): The last overload is declared here.
< /code>
Я нашел способ управлять им, обернув мой асинхронный обработчик в обычную функцию, но я не уверен, правильный ли это: < /p>
authRouter.post("/register", (req, res, next) => {
register(req, res, next);
});
Подробнее здесь: https://stackoverflow.com/questions/795 ... to-a-route