I am currently working on an Angular 15 application that is designed to showcase information about different games to users.
Within the application, I have a global object structured like this:
GAMES_INFO: {
skyroads: {
name: 'Sky Roads',
genre: GAMES_GENRES.action,
year: 1993,
wiki: 'https://en.wikipedia.org/wiki/SkyRoads_(video_game)',
},
prehistorik2: {
name: 'Prehistorik 2',
genre: GAMES_GENRES.arcade,
year: 1993,
wiki: 'https://en.wikipedia.org/wiki/Prehistorik_2',
},
}
My goal is to display game data to the user once they select a specific game:
Currently, using
this.gameInfo = dic.GAMES_INFO['skyroads'];
works perfectly. However, I would like the user to input the game name like this: this.gameInfo = dic.GAMES_INFO[gameName];
(where gameName
is a string)
Attempting this approach results in the error message
TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
.
Can anyone provide guidance on how to resolve this issue?