strictNullChecks

This commit is contained in:
Scott Anderson
2025-04-07 05:12:09 -04:00
parent aac1cf0754
commit 3b07f78e97
82 changed files with 582 additions and 423 deletions
+10 -4
View File
@@ -5,9 +5,9 @@ import { AStar, PathFindResultType, TileResult } from "./AStar";
import { MiniAStar } from "./MiniAStar";
export class PathFinder {
private curr: TileRef = null;
private dst: TileRef = null;
private path: TileRef[];
private curr: TileRef | null = null;
private dst: TileRef | null = null;
private path: TileRef[] | null = null;
private aStar: AStar;
private computeFinished = true;
@@ -63,7 +63,11 @@ export class PathFinder {
this.computeFinished = false;
return this.nextTile(curr, dst);
} else {
return { type: PathFindResultType.NextTile, tile: this.path.shift() };
const tile = this.path?.shift();
if (typeof tile === "undefined") {
throw new Error("missing tile");
}
return { type: PathFindResultType.NextTile, tile };
}
}
@@ -79,6 +83,8 @@ export class PathFinder {
return { type: PathFindResultType.Pending };
case PathFindResultType.PathNotFound:
return { type: PathFindResultType.PathNotFound };
default:
throw new Error("unexpected compute result");
}
}