Skip to content

Commit 6753299

Browse files
committed
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)
1 parent 66a3234 commit 6753299

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

src/main.ts

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
import { ErrorMapper } from "utils/ErrorMapper";
22

3+
declare global {
4+
/*
5+
Example types, expand on these or remove them and add your own.
6+
Note: Values, properties defined here do no fully *exist* by this type definiton alone.
7+
You must also give them an implemention if you would like to use them. (ex. actually setting a `role` property in a Creeps memory)
8+
9+
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).
10+
Interfaces matching on name from @types/screeps will be merged. This is how you can extend the 'built-in' interfaces from @types/screeps.
11+
*/
12+
// Memory extension samples
13+
interface Memory {
14+
uuid: number;
15+
log: any;
16+
}
17+
18+
interface CreepMemory {
19+
role: string;
20+
room: string;
21+
working: boolean;
22+
}
23+
24+
// Syntax for adding proprties to `global` (ex "global.log")
25+
namespace NodeJS {
26+
interface Global {
27+
log: any;
28+
}
29+
}
30+
}
31+
332
// When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change
433
// This utility uses source maps to get the line numbers and file names of the original, TS source code
534
export const loop = ErrorMapper.wrapLoop(() => {

src/types.d.ts

-20
This file was deleted.

0 commit comments

Comments
 (0)