Skip to content

Commit

Permalink
chore: use correct types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonappah committed Nov 19, 2024
1 parent d14acd3 commit eb78aa5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/server/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ apiRouter.get("/get-ids", (_, res) => {

apiRouter.get("/do-smth", async (_, res) => {
const robotsEntries = Array.from(virtualRobots.entries());
const randomRobotIndex = Math.floor(Math.random() * robotsEntries.length)
const [, robot] =
robotsEntries[Math.floor(Math.random() * robotsEntries.length)];
robotsEntries[randomRobotIndex];
await robot.sendDrivePacket(1);
await robot.sendTurnPacket(45 * DEGREE);

Expand Down
2 changes: 1 addition & 1 deletion src/server/api/client-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ClientManager {
}
}

public getIds(): undefined | string[] {
public getIds(): undefined | [string, string] {
if (this.hostId && this.clientId) {
return [this.hostId, this.clientId];
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/server/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const parseErrorStack = (stack: string): StackFrame[] => {
throw new Error(`Invalid stack frame: ${line}`);
}
const [, functionName, fileName, lineNumber, columnNumber] = match;
if (!functionName || !fileName || !lineNumber || !columnNumber) {
throw new Error(`Invalid stack frame: ${line}`);
}
return {
fileName,
functionName,
Expand Down

0 comments on commit eb78aa5

Please sign in to comment.