i had a code in javascript and I'm trying to convert it to typescript
var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
if (ip.substr(0, 7) == "::ffff:") {
ip = ip.substr(7);
this is a piece of my code which used to work correctly in js but now I get this error for substr
Property 'substr' does not exist on type 'string | string[]'. Property 'substr' does not exist on type 'string[]'.ts(2339)
I assume I should add type for ip
variable but I don't know what type should exactly be assigned to it.
any help would be appreciated