From fe923d6320e8ea23844bcc736b12f6f0a588a57c Mon Sep 17 00:00:00 2001 From: Eric Xu Date: Wed, 10 Jul 2024 20:47:13 -0400 Subject: [PATCH] Fix TS compiler error Need a cast to satisfy the type --- src/lib/MazeController.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/MazeController.ts b/src/lib/MazeController.ts index 190485e..a44b196 100644 --- a/src/lib/MazeController.ts +++ b/src/lib/MazeController.ts @@ -89,7 +89,9 @@ export class MazeController { await this.stopMazeAnimation(); const algType: Exclude = settings.generationAlgorithm === "random" - ? randomFromArray(GENERATION_ALGORITHMS.filter((x) => x !== "random")) + ? (randomFromArray( + GENERATION_ALGORITHMS.filter((x) => x !== "random"), + ) as Exclude) : settings.generationAlgorithm; const alg: MazeGenerator = match(algType) .with("backtracker", () => new Backtracker({ rows, cols })) @@ -165,7 +167,9 @@ export class MazeController { this.drawer.startEnd = [start, end]; const algType: Exclude = settings.solveAlgorithm === "random" - ? randomFromArray(SOLVE_ALGORITHMS.filter((x) => x !== "random")) + ? (randomFromArray( + SOLVE_ALGORITHMS.filter((x) => x !== "random"), + ) as Exclude) : settings.solveAlgorithm; const alg: MazeSolver = match(algType) .with("bfs", () => new BFS(this.maze!, start, end))