I'm working with an object that has an unknown format, specifically a users' CSV file. My task is to iterate through the keys to identify certain keys, such as phone numbers referenced as phoneNumbers1
, phoneNumbers2
, and so on in the .csv file.
How can I eliminate the //@ts-ignore
without facing any backlash? :)
const phoneNumbers = Object.keys(data)
//@ts-ignore
.filter((key) => key.includes("phoneNumbers") && !!data[p])
//@ts-ignore
.map((p) => ({ number: data[p], type: PHONE_TYPES.OFFICE }));
While attempting to access the information using data[p]
, I encounter the following error:
Element implicitly has an 'any' type because
expression of type 'string' can't be used to index type 'object'.
PS: data
is of type object
. At this point, I only know it is indeed an object (parse was successful), but the contents are still unknown.
I am aware that I could resort to using any
or other workarounds, but I am seeking a more elegant solution.