Typescript is raising the error "Element implicitly has an 'any' type because type 'HumansToDogs' has no index signature." on the following code.
Everything seems explicit and straightforward to me, can anyone help?
type HumanName = 'Jessie' | 'Mark';
type DogName = 'Spot' | 'Buddy';
type HumansToDogs = {
[key in HumanName]: DogName; // Isn't this an index signature?
}
const humansToDogs: HumansToDogs = {
'Jessie': 'Buddy',
'Mark': 'Spot',
};
for (const human in humansToDogs) {
const dog = humansToDogs[human]; // Index signature error here
}