Merge pull request #78 from PostCrafter/fix-tslint-issue

Fix TSLint issues
This commit is contained in:
Resi Respati
2017-12-22 20:48:49 +07:00
committed by GitHub
2 changed files with 7 additions and 6 deletions

View File

@@ -2,11 +2,11 @@ import { ErrorMapper } from "utils/ErrorMapper";
// 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(function() {
export const loop = ErrorMapper.wrapLoop(() => {
console.log(`Current game tick is ${Game.time}`);
// Automatically delete memory of missing creeps
for (let name in Memory.creeps) {
for (const name in Memory.creeps) {
if (!(name in Game.creeps)) {
delete Memory.creeps[name];
}

View File

@@ -38,8 +38,8 @@ export class ErrorMapper {
while (match = re.exec(stack)) {
if (match[2] === "main") {
const pos = this.consumer.originalPositionFor({
line: parseInt(match[3], 10),
column: parseInt(match[4], 10)
column: parseInt(match[4], 10),
line: parseInt(match[3], 10)
});
if (pos.line != null) {
@@ -75,7 +75,8 @@ export class ErrorMapper {
} catch (e) {
if (e instanceof Error) {
if ("sim" in Game.rooms) {
console.log(`<span style='color:red'>Source maps don't work in the simulator - displaying original error<br>${_.escape(e.stack)}</span>`)
const message = `Source maps don't work in the simulator - displaying original error`;
console.log(`<span style='color:red'>${message}<br>${_.escape(e.stack)}</span>`);
} else {
console.log(`<span style='color:red'>${_.escape(this.sourceMappedStackTrace(e))}</span>`);
}
@@ -84,6 +85,6 @@ export class ErrorMapper {
throw e;
}
}
}
};
}
}