October 25, 2024
Chicago 12, Melborne City, USA
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,

enter image description here

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

enter image description here

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

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video