OiO.lk Blog javascript Error while building node typescript app specifically in routes file
javascript

Error while building node typescript app specifically in routes file


I have created a routes file which has following code,

import express, { NextFunction, Request, Response } from "express";

const router = express.Router();

router.post(
  "/product",
  async (req: Request, res: Response, next: NextFunction) => {
    return res.status(200).json({});
  }
);

export default router;

See pretty simple just one route in there. But am having a red line under the 7th line of above code, let me show you how,

Running it locally works fine but when I try to build the code and try running the build code it throws an error,

Can anyone help if faced something similar before or know why is this happening? I have tried putting return type like Promise but that do not fixes the error I was thinking this might be an issue because of that.



You need to sign in to view this answers

Exit mobile version