Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
koesie10 committed Jan 15, 2025
1 parent 276405f commit 4607a45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion extensions/ql-vscode/src/common/jsonl-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export async function readJsonlFile<T>(
return new Promise((resolve, reject) => {
const stream = createReadStream(path, { encoding: "utf8" });
let buffer = "";
stream.on("data", async (chunk: string) => {
stream.on("data", async (chunk: string | Buffer) => {
if (typeof chunk !== "string") {
// This should never happen because we specify the encoding as "utf8".
throw new Error("Invalid chunk");
}

const parts = (buffer + chunk).split(doubleLineBreakRegexp);
buffer = parts.pop()!;
if (parts.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ describe("query-results", () => {
});

const finished = new Promise((res, rej) => {
validSarifStream.addListener("close", res);
validSarifStream.addListener("close", () => res(undefined));
validSarifStream.addListener("error", rej);
});

Expand Down Expand Up @@ -357,7 +357,7 @@ describe("query-results", () => {
});

const finished = new Promise((res, rej) => {
invalidSarifStream.addListener("close", res);
invalidSarifStream.addListener("close", () => res(undefined));
invalidSarifStream.addListener("error", rej);
});

Expand Down

0 comments on commit 4607a45

Please sign in to comment.