So, am trying to assign colours to my icons dynamically ... but this line of code keeps complaining,
let icon = iconsList[name];
When I hover of it .. This is the explanation "
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ heart: string; star: string; like: string; dislike: string; flash: string; marker: string; filter: string; user: string; circle: string; hashtag: string; calendar: string; chevronLeft: string; optionsV: string; optionsH: string; chat: string; explore: string; }'. No index signature with a parameter of type 'string' was found on type '{ heart: string; star: string; like: string; dislike: string; flash: string; marker: string; filter: string; user: string; circle: string; hashtag: string; calendar: string; chevronLeft: string; optionsV: string; optionsH: string; chat: string; explore: string; }'.ts(7053)
interface Props{ name:string,}const Icon = ({ name }:Props) => { const iconsList = { heart: '', star: '', like: '', dislike: '', flash: '', marker: '', filter: '', user: '', circle: '', hashtag: '', calendar: '', chevronLeft: '', optionsV: '', optionsH: '', chat: '', explore: '' }; let icon = iconsList[name]; icon = icon.substr(3); icon = String.fromCharCode(parseInt(icon, 16)); return icon; }; export default Icon;
ScreenShot of the code in Vscode On line 25, am trying to pick the specific icon color but it complains