I am struggling to get this to function correctly
interface ObjectPool<Ids, T> {
pool: {
[K in Ids]: T<K>;
};
};
interface Player<Id> {
id: Id;
}
let playerPool: ObjectPool<0 | 1 | 2, Player>;
in a way that
playerPool[0].id === 0;
playerPool[1].id === 1;
playerPool[2].id === 2;
// playerPool[3] error
however TypeScript is indicating that I require a generic parameter at Player
in
let playerPool: ObjectPool<0 | 1 | 2, Player>;
so I attempted let playerPool: ObjectPool<0 | 1 | 2, Player<_>>;
but it did not resolve the issue either