Result of room.lookForAtArea(..., false) is wrongly typed.
zyzyzyryxy opened this issue · comments
Room.lookForAtArea can return results in multiple formats. Not all are currently tested and not all are correctly typed.
Expected Behavior
Following code is working and should pass type checking.
Actual Behavior
s is typed as an object with two fields, type
and structure
. This is not what the game returns. As a result, following misleading error is returned for s.structureType:
Property 'structureType' does not exist on type 'LookForAtAreaResult<Structure, "structure">'. Did you mean 'structure'?ts(2551)
Sample code (if available)
const room = Game.rooms.W33S45, x = 21, y = 23;
room.lookForAtArea(LOOK_STRUCTURES, y, x, y, x)[y][x].find(s => s.structureType === STRUCTURE_CONTROLLER)
Your Environment
- Node.js version: v8.11.1 and v21.5.0
- TypeScript version: 4.6
- typed-screeps version: v3.3.1
I think I fixed it already: #253