I have the following code to check whether there was an error starting Express:
express()
.listen(port, (err: Error) => {
if (err) {
console.error(err);
return;
}
console.log(`Express started`);
});
However, recently, I'm getting this error in Typescript compiler:
TS2345: Argument of type '(err: Error) => void' is not assignable to parameter of type '(() => void) | undefined'.
It seems like the callback function of listen() doesn't take in an error parameter. If this is the case, how should I check and handle errors when starting Express?