Skip to content

Fix @ts-check regressions in setup JS scripts causing CI js job failure#27060

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-tests
Apr 18, 2026
Merged

Fix @ts-check regressions in setup JS scripts causing CI js job failure#27060
pelikhan merged 3 commits intomainfrom
copilot/fix-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

The CI js job failed on tsc --noEmit due to stricter JSDoc type checking across workflow-comment, reviewer, invocation-context, and gateway-config scripts. This change narrows nullable/object inputs explicitly so existing behavior remains type-safe under @ts-check.

  • Reviewer request typing (add_reviewer.cjs)

    • Added an explicit prNumber === null guard before constructing the reviewer request payload.
    • Removes the number | null assignment path to pull_number: number.
  • Invocation context typing (add_workflow_run_comment.cjs, invocation_context_helpers.cjs)

    • Added a concrete JSDoc type for the optional invocationContext argument in addCommentWithWorkflowLink.
    • Reworked repo/payload object narrowing to avoid unsafe property access on generic object values.
  • Gateway config object normalization (convert_gateway_config_shared.cjs, convert_gateway_config_codex.cjs)

    • Normalized mcpServers using Object.fromEntries(Object.entries(...)) into a typed record.
    • Converted dynamic headers into Record<string, string> by filtering non-string header values before using Authorization.
/** @type {Record<string, string>} */
const headers =
  rawHeaders && typeof rawHeaders === "object" && !Array.isArray(rawHeaders)
    ? Object.fromEntries(Object.entries(rawHeaders).filter(([, v]) => typeof v === "string"))
    : {};
const authKey = headers.Authorization || "";

Copilot AI and others added 3 commits April 18, 2026 15:49
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/abb93850-d2bc-4346-857c-01913c585678

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/abb93850-d2bc-4346-857c-01913c585678

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review April 18, 2026 16:21
Copilot AI review requested due to automatic review settings April 18, 2026 16:21
@pelikhan pelikhan merged commit 303574b into main Apr 18, 2026
53 checks passed
@pelikhan pelikhan deleted the copilot/fix-tests branch April 18, 2026 16:21
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 CI js job failures caused by stricter @ts-check / JSDoc type checking in the Actions setup JS scripts, by adding explicit narrowing and more precise JSDoc types.

Changes:

  • Add explicit prNumber === null guard in add_reviewer.cjs to keep reviewer payload types non-nullable.
  • Tighten invocation context and payload/repo extraction typing/narrowing to avoid unsafe property access under @ts-check.
  • Normalize gateway config objects (servers + headers) to typed records using Object.fromEntries(...) with filtering for string header values.
Show a summary per file
File Description
actions/setup/js/invocation_context_helpers.cjs Replaces any casts with explicit object-shape narrowing for repo/payload extraction.
actions/setup/js/convert_gateway_config_shared.cjs Normalizes mcpServers into a new object via Object.entries/Object.fromEntries.
actions/setup/js/convert_gateway_config_codex.cjs Filters dynamic header values to Record<string, string> before using Authorization.
actions/setup/js/add_workflow_run_comment.cjs Adds explicit JSDoc typing for optional invocationContext parameter.
actions/setup/js/add_reviewer.cjs Adds explicit guard to prevent null PR number from flowing into API request payload typing.

Copilot's findings

Tip

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

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

let servers = {};
if (rawServers && typeof rawServers === "object" && !Array.isArray(rawServers)) {
servers = /** @type {Record<string, Record<string, unknown>>} */ rawServers;
servers = Object.fromEntries(Object.entries(rawServers));
Comment on lines +232 to +236
* source: "native" | "workflow_dispatch" | "repository_dispatch";
* eventName: string;
* eventPayload: any;
* workflowRepo: { owner: string, repo: string };
* eventRepo: { owner: string, repo: string };
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