0
respostas

[Dúvida] Uso do método .criaPet como route handler

Ao refazer localmente o código da aula criei um erro ao escrever o arquivo petRouter.ts enquanto passando o método .criaPet da instância petController diretamente como um router handler. Existe alguma correção? Segue código e erro, respectivamente.

./src/petRouter.ts

import express from "express";
import PetController from "../controller/PetController";

const router=express.Router();

const petController = new PetController();

router.post("/", petController.criaPet);

export default router;

Erro: [{ "resource": "/home/igor/Alura/typescript-para-backend/src/routes/petRouter.ts", "owner": "typescript", "code": "2769", "severity": 8, "message": "No overload matches this call.\n The last overload gave the following error.\n Argument of type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Response<...>' is not assignable to parameter of type 'Application<Record<string, any>>'.\n Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>) => Response<...>' is missing the following properties from type 'Application<Record<string, any>>': init, defaultConfiguration, engine, set, and 63 more.", "source": "ts", "startLineNumber": 8, "startColumn": 18, "endLineNumber": 8, "endColumn": 39, "relatedInformation": [ { "startLineNumber": 164, "startColumn": 5, "endLineNumber": 164, "endColumn": 56, "message": "The last overload is declared here.", "resource": "/home/igor/Alura/typescript-para-backend/node_modules/@types/express-serve-static-core/index.d.ts" } ] }]