Skip to content

Fix copilot_driver JSDoc callback typing to unblock JS CI typecheck#26786

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-tests-yet-again
Apr 17, 2026
Merged

Fix copilot_driver JSDoc callback typing to unblock JS CI typecheck#26786
pelikhan merged 2 commits intomainfrom
copilot/fix-tests-yet-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

The CI js job failed in tsc --noEmit due to an incompatible JSDoc function type in copilot_driver.cjs: fs.appendFileSync was not assignable to the narrower callback signature used by appendSafeOutputLine. This change aligns the type contracts so both production and test call sites are valid.

  • Type contract fix for safe-output append callback

    • Broadened the callback type accepted by appendSafeOutputLine to support both:
      • Node fs.appendFileSync signature (PathOrFileDescriptor, string | Uint8Array, WriteFileOptions?)
      • String-only test stub signature (path: string, data: string, encoding: string)
  • Consistency in infrastructure incomplete emitter

    • Applied the same callback type to emitInfrastructureIncomplete options so injected writers and default fs.appendFileSync share one compatible contract.
  • JSDoc cleanup for maintainability

    • Extracted repeated union signatures into shared typedefs:
      • NodeAppendFileSync
      • StringAppendLineWriter
      • AppendFileSyncLike
/**
 * @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} NodeAppendFileSync
 * @typedef {(path: string, data: string, encoding: string) => void} StringAppendLineWriter
 * @typedef {NodeAppendFileSync | StringAppendLineWriter} AppendFileSyncLike
 */

/** @param {AppendFileSyncLike} appendFileSync */
function appendSafeOutputLine(appendFileSync, safeOutputsPath, payload) {
  appendFileSync(safeOutputsPath, payload + "\n", "utf8");
}

@pelikhan pelikhan marked this pull request as ready for review April 17, 2026 01:46
Copilot AI review requested due to automatic review settings April 17, 2026 01:46
@pelikhan pelikhan merged commit b17e0b7 into main Apr 17, 2026
55 checks passed
@pelikhan pelikhan deleted the copilot/fix-tests-yet-again branch April 17, 2026 01:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes JSDoc typing for injected “append file” callbacks in copilot_driver.cjs so tsc --noEmit accepts both the production writer (fs.appendFileSync) and test stubs.

Changes:

  • Introduces shared JSDoc typedefs for append-writer function shapes.
  • Broadens appendSafeOutputLine’s appendFileSync parameter type to a reusable union type.
  • Applies the same callback type to emitInfrastructureIncomplete options for consistency.
Show a summary per file
File Description
actions/setup/js/copilot_driver.cjs Adds shared JSDoc typedefs and updates callback types used for safe-output/infrastructure-incomplete emission.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +65 to +69
* @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} NodeAppendFileSync
*/

/**
* @typedef {(path: string, data: string, encoding: string) => void} StringAppendLineWriter
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NodeAppendFileSync doesn't match Node's fs.appendFileSync overloads: the third parameter can be a BufferEncoding string (e.g. "utf8") or an options object. As written (options?: WriteFileOptions), appendSafeOutputLine(..., "utf8") is not type-safe for the NodeAppendFileSync branch, so the AppendFileSyncLike union still won't typecheck. Broaden the third parameter type (e.g. WriteFileOptions | import("node:buffer").BufferEncoding) or change the call site to pass an options object (and update the string-writer typedef accordingly).

Suggested change
* @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions) => void} NodeAppendFileSync
*/
/**
* @typedef {(path: string, data: string, encoding: string) => void} StringAppendLineWriter
* @typedef {(path: import("node:fs").PathOrFileDescriptor, data: string | Uint8Array, options?: import("node:fs").WriteFileOptions | import("node:buffer").BufferEncoding) => void} NodeAppendFileSync
*/
/**
* @typedef {(path: string, data: string, encoding: import("node:buffer").BufferEncoding) => void} StringAppendLineWriter

Copilot uses AI. Check for mistakes.
This was referenced Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants