diff --git a/dist/index.d.ts b/dist/index.d.ts index 97ea185..68c5c5b 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1746,7 +1746,7 @@ type BodyPartDefinition = T exten * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ - boost?: keyof typeof BOOSTS[T]; + boost?: keyof (typeof BOOSTS)[T]; /** * One of the body part types constants. */ @@ -1790,6 +1790,15 @@ type StoreDefinitionUnlimited = Store; // energy: number; // } +/** + * @example + * { + * "1": "W8N4", // TOP + * "3": "W7N3", // RIGHT + * // "5": "W8N2", // BOTTOM + * "7": "W9N3" // LEFT + * } + */ type ExitsInformation = Partial>; interface AllLookAtTypes { @@ -2796,7 +2805,7 @@ interface GameMap { * @param roomName The room name. * @returns The exits information or null if the room not found. */ - describeExits(roomName: string): ExitsInformation; + describeExits(roomName: string): ExitsInformation | null; /** * Find the exit direction from the given room en route to another room. * @param fromRoom Start room name or room object. diff --git a/dist/screeps-tests.ts b/dist/screeps-tests.ts index 71cbe75..6d28386 100644 --- a/dist/screeps-tests.ts +++ b/dist/screeps-tests.ts @@ -236,13 +236,15 @@ function resources(o: GenericStore): ResourceConstant[] { { const exits = Game.map.describeExits("W8N3"); - // tslint:disable-next-line:newline-per-chained-call - keys(exits).map((exitKey) => { - const nextRoom = exits[exitKey]; - const exitDir = +exitKey as ExitConstant; - const exitPos = creep.pos.findClosestByRange(exitDir); - return { nextRoom, exitPos }; - }); + if (exits) { + // tslint:disable-next-line:newline-per-chained-call + keys(exits).map((exitKey) => { + const nextRoom = exits[exitKey]; + const exitDir = +exitKey as ExitConstant; + const exitPos = creep.pos.findClosestByRange(exitDir); + return { nextRoom, exitPos }; + }); + } } // Game.map.findExit() diff --git a/src/helpers.ts b/src/helpers.ts index 78d5faa..62519b7 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -147,7 +147,7 @@ type BodyPartDefinition = T exten * * If the body part is boosted, this property specifies the mineral type which is used for boosting. */ - boost?: keyof typeof BOOSTS[T]; + boost?: keyof (typeof BOOSTS)[T]; /** * One of the body part types constants. */ @@ -191,6 +191,15 @@ type StoreDefinitionUnlimited = Store; // energy: number; // } +/** + * @example + * { + * "1": "W8N4", // TOP + * "3": "W7N3", // RIGHT + * // "5": "W8N2", // BOTTOM + * "7": "W9N3" // LEFT + * } + */ type ExitsInformation = Partial>; interface AllLookAtTypes { diff --git a/src/map.ts b/src/map.ts index 53f4d4f..0074e13 100644 --- a/src/map.ts +++ b/src/map.ts @@ -26,7 +26,7 @@ interface GameMap { * @param roomName The room name. * @returns The exits information or null if the room not found. */ - describeExits(roomName: string): ExitsInformation; + describeExits(roomName: string): ExitsInformation | null; /** * Find the exit direction from the given room en route to another room. * @param fromRoom Start room name or room object.