Typescript Overloaded Function Typescript Overloaded Function express express

Typescript Overloaded Function


I have experienced the same issue today.Not sure about the real reason for this to happen but I have fixed it by passing arguments through the method call.

server.listen.call(server, 4000, '0.0.0.0', () => {  console.log(server.address()) // output is { address: '0.0.0.0', family: 'IPv4', port: 4000 }});


You have a type mismatch.process.env.PORT is of type string while the function accepts number.This should fix it:

const port = Number(process.env.PORT) || 3000;