Skip to content

Commit

Permalink
fix: @typescript-eslint/no-non-null-assertion warnings (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
teppeis committed Aug 3, 2022
1 parent 00f33c6 commit 9c055d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export async function createCompilerOptionsForChunks(
.map((inputs) => [...inputs])
.flat();
compilerOptions.chunk = sortedChunkIds.map((id) => {
const numOfInputs = chunkToInputPathSet.get(id)!.size;
const numOfInputs = assertNonNullable(chunkToInputPathSet.get(id)).size;
return `${id}:${numOfInputs}:${chunks[id].deps.join(",")}`;
});
compilerOptions.chunk_wrapper = createChunkWrapper(
Expand Down
13 changes: 9 additions & 4 deletions src/dag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Zet from "zet";
import { assertNonNullable } from "./assert";

export class Node {
id: string;
Expand Down Expand Up @@ -53,7 +54,7 @@ export class Dag {
// populate children (inverting deps)
nodes.forEach((node) => {
node.deps.forEach((dep) => {
this.idToNode.get(dep)!.children.add(node);
assertNonNullable(this.idToNode.get(dep)).children.add(node);
});
});
this.populateDepth();
Expand All @@ -74,7 +75,10 @@ export class Dag {
}
ancestors.push(node.id);
node.deps.forEach((dep) => {
this.populateAncestors(this.idToNode.get(dep)!, ancestors);
this.populateAncestors(
assertNonNullable(this.idToNode.get(dep)),
ancestors
);
});
return ancestors;
}
Expand Down Expand Up @@ -150,15 +154,16 @@ export class Dag {
for (const ancestor of commonAncestors) {
if (
least === null ||
this.idToDepth.get(least)! < this.idToDepth.get(ancestor)!
assertNonNullable(this.idToDepth.get(least)) <
assertNonNullable(this.idToDepth.get(ancestor))
) {
least = ancestor;
}
}
if (!least) {
throw new Error("LCA not found");
}
result = this.idToNode.get(least)!;
result = assertNonNullable(this.idToNode.get(least));
this.setLcaCache(u, v, result);
return result;
}
Expand Down

0 comments on commit 9c055d9

Please sign in to comment.