I have an Angular 15 application which shows games information for users.
I have a global object that look something 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',
},
}
And I want to display data to the user once he selects a game:
Doing the following works well this.gameInfo = dic.GAMES_INFO['skyroads'];
But, I would like the game name to be an input from the user like this: this.gameInfo = dic.GAMES_INFO[gameName];
(gameName
is a string)
This result in an the following error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type
.
How do can I fix that?