From b42717e7721da670dc59a2e56ad16269716bbcca Mon Sep 17 00:00:00 2001 From: Daniel Berndt Date: Sat, 21 Oct 2017 23:31:24 +0200 Subject: [PATCH] Make memory extensible --- src/creep.ts | 3 ++- src/flag.ts | 4 +++- src/room.ts | 4 +++- src/spawn.ts | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/creep.ts b/src/creep.ts index c5adecb..9459da7 100644 --- a/src/creep.ts +++ b/src/creep.ts @@ -42,7 +42,7 @@ interface Creep extends RoomObject { /** * A shorthand to Memory.creeps[creep.name]. You can use it for quick access the creep’s specific memory data object. */ - memory: any; + memory: CreepMemory; /** * Whether it is your creep or foe. */ @@ -230,5 +230,6 @@ interface Creep extends RoomObject { interface CreepConstructor extends _Constructor, _ConstructorById { } +interface CreepMemory { } declare const Creep: CreepConstructor; diff --git a/src/flag.ts b/src/flag.ts index a3805e3..52bb9a7 100644 --- a/src/flag.ts +++ b/src/flag.ts @@ -11,7 +11,7 @@ interface Flag extends RoomObject { /** * A shorthand to Memory.flags[flag.name]. You can use it for quick access the flag's specific memory data object. */ - memory: any; + memory: FlagMemory; /** * Flag’s name. You can choose the name while creating a new flag, and it cannot be changed later. This name is a hash key to access the spawn via the Game.flags object. */ @@ -52,4 +52,6 @@ interface FlagConstructor extends _Constructor { (name: string, color: number, secondaryColor: number, roomName: string, x: number, y: number): Flag; } +interface FlagMemory { } + declare const Flag: FlagConstructor; diff --git a/src/room.ts b/src/room.ts index 287afe1..615f798 100644 --- a/src/room.ts +++ b/src/room.ts @@ -19,7 +19,7 @@ interface Room { /** * A shorthand to Memory.rooms[room.name]. You can use it for quick access the room’s specific memory data object. */ - memory: any; + memory: RoomMemory; /** * One of the following constants: * MODE_SIMULATION, MODE_SURVIVAL, MODE_WORLD, MODE_ARENA @@ -170,4 +170,6 @@ interface RoomConstructor { deserializePath(path: string): PathStep[]; } +interface RoomMemory { } + declare const Room: RoomConstructor; diff --git a/src/spawn.ts b/src/spawn.ts index 5205eb5..a62a8bb 100644 --- a/src/spawn.ts +++ b/src/spawn.ts @@ -33,7 +33,7 @@ interface StructureSpawn extends OwnedStructure { /** * A shorthand to Memory.spawns[spawn.name]. You can use it for quick access the spawn’s specific memory data object. */ - memory: any; + memory: SpawnMemory; /** * Spawn’s name. You choose the name upon creating a new spawn, and it cannot be changed later. This name is a hash key to access the spawn via the Game.spawns object. */ @@ -120,4 +120,6 @@ interface StructureSpawn extends OwnedStructure { interface StructureSpawnConstructor extends _Constructor, _ConstructorById { } +interface SpawnMemory { } + declare const StructureSpawn: StructureSpawnConstructor;