[TASK] Fixed some stuff in the last couple of days, so the firebase eslint is happy again

This commit is contained in:
2021-12-16 22:57:29 +01:00
parent 1e405e982a
commit 4137cef6f9
4 changed files with 11 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ class Grid<T> {
return this.data[this.index(x, y)];
}
setAt(x: number, y: number, value: T) {
setAt(x: number, y: number, value: T): void {
if (!this.isInBounds(x, y)) {
throw Error(`Invalid coordinate: (${x}, ${y})`);
@@ -53,7 +53,7 @@ class Grid<T> {
return x >= 0 && x < this.maxX && y >= 0 && y < this.maxY;
}
inBoundsNeighbors(x: number, y: number, includeDiagonal: boolean = false): Vector2[] {
inBoundsNeighbors(x: number, y: number, includeDiagonal = false): Vector2[] {
const res = [
new Vector2(x + 1, y),
@@ -75,7 +75,7 @@ class Grid<T> {
/**
* Pastes the given grid into this grid, with it's top left position at the given coordinate
*/
paste(grid: Grid<T>, posX: number, posY: number) {
paste(grid: Grid<T>, posX: number, posY: number): void {
if (posX + grid.maxX > this.maxX || posY + grid.maxY > this.maxY) throw Error(`Can't paste grid at (${posX}, ${posY}), this grid is not big enough`);

View File

@@ -76,7 +76,7 @@ class Day14 implements Day {
const { orig, mapping } = Day14.parseInput(input);
let counts: CharCounts = {};
const counts: CharCounts = {};
const cache = new Map<string, CharCounts>();
for (let i = 0; i < orig.length - 1; i++) {
@@ -120,7 +120,7 @@ class Day14 implements Day {
}
mergeIntoLeft(left: CharCounts, right: CharCounts) {
mergeIntoLeft(left: CharCounts, right: CharCounts): void {
for (const rightKey in right) {
if (rightKey in left) {
@@ -131,7 +131,7 @@ class Day14 implements Day {
}
}
addOne(char: string, counts: CharCounts) {
addOne(char: string, counts: CharCounts): void {
if (char in counts) {
counts[char]++;

View File

@@ -42,7 +42,10 @@ class Day15 implements Day {
// Simulate a priority queue on distance:
searchStack.sort((a, b) => distances.at(b.x, b.y) - distances.at(a.x, a.y));
const cur = searchStack.pop()!;
const cur = searchStack.pop();
if (!cur) throw Error("???");
if (cur.x === destination.x && cur.y === destination.y) {
break;
}

View File

@@ -92,7 +92,7 @@ class Packet {
return input.split("").map(s => parseInt(s, 16).toString(2).padStart(4, "0")).join("");
}
static parseBinaryInput(binaryInput: string, start: number = 0): Packet {
static parseBinaryInput(binaryInput: string, start = 0): Packet {
const version = parseInt(binaryInput.substr(start, Packet.VERSION_LENGTH), 2);
const type = parseInt(binaryInput.substr(start + Packet.VERSION_LENGTH, Packet.TYPE_LENGTH), 2);