diff --git a/src/main.ts b/src/main.ts index bd762c4..3b29f3e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,34 @@ import { ErrorMapper } from "utils/ErrorMapper"; +declare global { + /* + Example types, expand on these or remove them and add your own. + Note: Values, properties defined here do no fully *exist* by this type definiton alone. + You must also give them an implemention if you would like to use them. (ex. actually setting a `role` property in a Creeps memory) + + Types added in this `global` block are in an ambient, global context. This is needed because `main.ts` is a module file (uses import or export). + Interfaces matching on name from @types/screeps will be merged. This is how you can extend the 'built-in' interfaces from @types/screeps. + */ + // Memory extension samples + interface Memory { + uuid: number; + log: any; + } + + interface CreepMemory { + role: string; + room: string; + working: boolean; + } + + // Syntax for adding proprties to `global` (ex "global.log") + namespace NodeJS { + interface Global { + log: any; + } + } +} + // When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change // This utility uses source maps to get the line numbers and file names of the original, TS source code export const loop = ErrorMapper.wrapLoop(() => { diff --git a/src/types.d.ts b/src/types.d.ts deleted file mode 100644 index 00727b9..0000000 --- a/src/types.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -// example declaration file - remove these and add your own custom typings - -// memory extension samples -interface CreepMemory { - role: string; - room: string; - working: boolean; -} - -interface Memory { - uuid: number; - log: any; -} - -// `global` extension samples -declare namespace NodeJS { - interface Global { - log: any; - } -}