interfaceServerConfig{port: null|string|number;}typeRequestHandler=(request: Request,response: Response)=>void;// Exclude `null` type from `null | string | number`.// In case the port is equal to `null`, we will use default value.functiongetPortValue(port: Exclude<ServerConfig["port"],null>):number{if(typeofport==="string"){returnparseInt(port,10);}returnport;}functionstartServer(handler: RequestHandler,config: ServerConfig):void{constserver=require("http").createServer(handler);constport=config.port===null?3000 : getPortValue(config.port);server.listen(port);}