Skip to content

Instantly share code, notes, and snippets.

@dmecke
Last active November 29, 2016 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmecke/0df7b329fef6c044ff3b51eed94164b7 to your computer and use it in GitHub Desktop.
Save dmecke/0df7b329fef6c044ff3b51eed94164b7 to your computer and use it in GitHub Desktop.
The compiler complains about "property 'state' does not exist on type 'Creep'''. It seems main.ts knows about the interface, but not about the implementation. Or is it the other way around?
// src/Screeps/Creep.ts
Creep.prototype.role = function() {
return this.memory.role;
};
// typings/custom/screeps/index.d.ts
export interface Creep {
role(): string;
}
// src/main.ts
export function loop() {
for (let name in Game.creeps) {
if (Game.creeps.hasOwnProperty(name)) {
console.log(Game.creeps[name].role());
}
}
}
// tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6"
},
"include": [
"typings/**/*.d.ts",
"src/**/*.ts"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment