You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 :)
typed-screeps-arena/dist/game/utils.d.ts
Lines 29 to 32 in 75014a1
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.The text was updated successfully, but these errors were encountered: