I have a JSON file containing IDs as keys like this:
"1" : { "key": "value"},
"2" : { "key": "value"},
In my class, I import this JSON file as a data object and then use the ID passed to a method to retrieve the corresponding object, as shown below:
getData = (id: string) {
this.temp = data[id]
}
However, I am encountering the following error message. While it does not cause any runtime issues, it is hindering my unit testing and showing up as an error in my editor.
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type {"1" : { "key": string};
"2" : { "key": string};}