I have an object named "containers" that will always contain the same type of component on every key.
The code snippet below functions as intended
interface Dictionary<T> {
[key: string]: T;
}
interface GameContainer {
zIndex: number;
}
interface Game {
containers: Dictionary<GameContainer>;
}
const game: Game = {
containers: {
a: { zIndex: 2 },
b: { zIndex: 4 }
}
}
An issue arises when attempting to map over "containers"
const something = game.containers.map(container => {
console.log(container)
})
Upon trying this, I encounter the following error message
Cannot invoke an expression whose type lacks a call signature. Type 'GameContainer' has no compatible call signatures.
This error seems unusual to me because it should work in vanilla JavaScript.
You can click here for a link to a typescript playground to observe the error