Why do I get this error?
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ 0: string; 1: string; 2: string; 3: string; }'.
No index signature with a parameter of type 'string' was found on type '{ 0: string; 1: string; 2: string; 3: string; }'.ts(7053)
this is my code: I specifically made the index a string so there should be no problem, but my StatusMap variable gives me this red flag..
const getStatusMeaning = (index: string) => {
const StatusMap = {
'0': 'Unknown',
'1': 'Pending',
'2': 'Success',
'3': 'Failure',
}
return StatusMap[index]
}

"hello"is a valid index. What do you thinkStatusMap["hello"]would produce? Certainly not any of these values, hence TS downgrades it to "any" (or upgrade, depending on how you look at it).