Remove types.d.ts

Moves example type definitions to main.ts from types.d.ts
Adds additional documentation to example types
Removes types.d.ts file (fixes #147)
This commit is contained in:
Skyler Kehren
2021-05-09 22:38:37 +03:00
parent 66a323425e
commit 675329997a
2 changed files with 29 additions and 20 deletions

View File

@@ -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(() => {

20
src/types.d.ts vendored
View File

@@ -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;
}
}