Open ngbrown opened 3 years ago
Sounds like a good idea, I guess that is what the types for Screeps: World does based on the FIND_XX constant you give the find methods. Not sure AllGameObjects should contain GameObject
though?
Feel free to make a PR for the relevant changes :)
coming back to this, @ngbrown have you tested this? i am not sure about possible side effects of arena specific types being included in your union 🤔
Hi @lmik. It did work last time I tried it, but that was back in the closed alpha...
https://github.com/screepers/typed-screeps-arena/blob/75014a14c4ca0a5f1790b9aa55d7f7a45a4ad718/dist/game/utils.d.ts#L29-L32
The current return type of
GameObject[]
doesn't avail its self of being able to discriminate into specific objects. For example, I would expect the following to work:But it doesn't because TypeScript doesn't assume that an array of a base type could be any implementation of it. I propose that a union type be created of all the items that could be returned and
getObjects()
returns that type of array.