I have an icon-Map.json which is being created dynamically. Example:
const iconMap = {
angleDoubleRight: 'angleDoubleRight.svg',
angleRight: 'angleRight.svg',
assets: 'assets.svg',
barChart: 'barChart.svg',
cancel: 'cancel.svg',
chevronDown: 'chevronDown.svg',
dotChart: 'dotChart.svg',
dotMenu: 'dotMenu.svg',
horizontalDots: 'horizontalDots.svg'
...
};
I can't create an interface manually from this object because I'm creating it dynamically so I can't use keyof.
Eventually, I want to create a type of iconMap's keys which I can use outside a component and it will strict my input to iconMap's keys only. (union or enum):
type IconMapMember = 'angleDoubleRight' | 'angleRight' | 'assets' | ....
type IconMapMember = 'angleDoubleRight' | 'angleRight'|...
then what are you going to do after adding a new property to theiconMap
object? Types cannot be modified in runtime, they are for compile time. – Lochia