How to fix Argument of type 'undefined' is not assignable to parameter of type 'string | undefined' in TypeScript | DevErrors