DEV Community

Discussion on: Developing an Express Application Using TypeScript

Collapse
 
sufianbabri profile image
Sufian Babri

Nice article. I've got a question and a suggestion. :)

The question: your "start" script is using ts-node, shouldn't it use node because it'd be an overkill otherwise? Maybe some performance issue?

The suggestion: in the following line, instead of not declaring the type of the parameter "next" which defaults to any, you can declare it of type NextFunction:

const loggerMiddleware = (req: Request, resp: Response, next) => {
Enter fullscreen mode Exit fullscreen mode

So, to import NextFunction, you can replace import { Request, Response } from 'express' with:

import { Request, Response, NextFunction } from 'express'
Enter fullscreen mode Exit fullscreen mode