Skip to content

Commit 525dab3

Browse files
authored
Fix copilot_driver.cjs append callback typing mismatch in TypeScript checks (#27236)
1 parent ef07056 commit 525dab3

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

actions/setup/js/copilot_driver.cjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,7 @@ const MODEL_NOT_SUPPORTED_PATTERN = /The requested model is not supported/;
6262
const NO_AUTH_INFO_PATTERN = /No authentication information found/;
6363

6464
/**
65-
* @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} NodeAppendFileSync
66-
*/
67-
68-
/**
69-
* @typedef {(path: string, data: string, encoding: string) => void} StringAppendLineWriter
70-
*/
71-
72-
/**
73-
* @typedef {NodeAppendFileSync | StringAppendLineWriter} AppendFileSyncLike
65+
* @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} AppendFileSyncLike
7466
*/
7567

7668
/**
@@ -154,7 +146,7 @@ function buildInfrastructureIncompletePayload(details) {
154146
* @param {string} payload
155147
*/
156148
function appendSafeOutputLine(appendFileSync, safeOutputsPath, payload) {
157-
appendFileSync(safeOutputsPath, payload + "\n", "utf8");
149+
appendFileSync(safeOutputsPath, payload + "\n", { encoding: "utf8" });
158150
}
159151

160152
/**

actions/setup/js/copilot_driver.test.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ describe("copilot_driver.cjs", () => {
151151

152152
it("appends one JSONL line through appendSafeOutputLine", () => {
153153
const writes = [];
154-
const appendStub = (file, data, encoding) => writes.push({ file, data, encoding });
154+
const appendStub = (file, data, options) => writes.push({ file, data, options });
155155
appendSafeOutputLine(appendStub, "/tmp/safeoutputs.jsonl", '{"type":"report_incomplete"}');
156-
expect(writes).toEqual([{ file: "/tmp/safeoutputs.jsonl", data: '{"type":"report_incomplete"}\n', encoding: "utf8" }]);
156+
expect(writes).toEqual([{ file: "/tmp/safeoutputs.jsonl", data: '{"type":"report_incomplete"}\n', options: { encoding: "utf8" } }]);
157157
});
158158

159159
it("emitInfrastructureIncomplete writes payload when path is configured", () => {
160160
const writes = [];
161161
const logs = [];
162162
emitInfrastructureIncomplete("temporary outage", {
163163
safeOutputsPath: "/tmp/safeoutputs.jsonl",
164-
appendFileSync: (file, data, encoding) => writes.push({ file, data, encoding }),
164+
appendFileSync: (file, data, options) => writes.push({ file, data, options }),
165165
logger: message => logs.push(message),
166166
});
167167
expect(writes).toHaveLength(1);

0 commit comments

Comments
 (0)