Skip to content

fix: resolve TypeScript typecheck errors in JS files#30026

Merged
pelikhan merged 1 commit intomainfrom
copilot/fix-issue-referencing-link
May 3, 2026
Merged

fix: resolve TypeScript typecheck errors in JS files#30026
pelikhan merged 1 commit intomainfrom
copilot/fix-issue-referencing-link

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

The js-typecheck CI job was failing with 8 TypeScript errors across 4 files introduced by stricter type inference.

Changes

  • aw_context.cjs: Add parentheses to JSDoc type cast — /** @type {T} */ (expr) is required syntax; without them the cast is silently ignored and TypeScript sees object instead of Record<string, unknown>

  • handle_agent_failure.cjs: Remove erroneous /** @type {Array<any>} */ annotations on resolvedItems — the optional items param is Array<any> | undefined, conflicting with the forced Array<any> annotation; TypeScript narrows correctly after the null-check/early-return block without the annotation

  • handle_agent_failure.cjs + missing_info_formatter.cjs: Widen formatMissingTools and escapeMarkdown parameter types to accept string | null, matching the actual return type of loadMissingToolMessages (tool field is string | null)

  • pick_experiment.cjs: Add ms != null && guard before ms > 0 (TypeScript doesn't narrow through Number.isInteger); use ?? 0 fallback for minSamples since the outer progressNames filter already guarantees it's a positive integer

  • setup_globals.cjs: Change @param {typeof github} to @param {any}typeof github created a TS2502 circular self-reference because TypeScript was inferring the global github type through the global.github = createRateLimitAwareGithub(githubModule) assignment in the same function

@pelikhan pelikhan marked this pull request as ready for review May 3, 2026 22:57
Copilot AI review requested due to automatic review settings May 3, 2026 22:57
@pelikhan pelikhan merged commit ec9c3af into main May 3, 2026
8 of 9 checks passed
@pelikhan pelikhan deleted the copilot/fix-issue-referencing-link branch May 3, 2026 22:57
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

Resolves js-typecheck CI failures by adjusting JSDoc typing and adding small runtime guards so TypeScript can correctly narrow types in @ts-check’d .cjs files.

Changes:

  • Fix JSDoc cast syntax in aw_context.cjs so TypeScript applies the intended Record<string, unknown> type.
  • Align missing-tool formatting types with actual nullable fields produced by agent-output parsing.
  • Add null/undefined guards and safe fallbacks in experiment summary generation; relax a problematic JSDoc type in globals setup to avoid circular typing.
Show a summary per file
File Description
actions/setup/js/setup_globals.cjs Adjusts JSDoc typing for the injected GitHub client/module parameter to avoid a TS circular reference.
actions/setup/js/pick_experiment.cjs Adds an explicit nullish guard for min_samples filtering and a ?? 0 fallback for summary calculations.
actions/setup/js/missing_info_formatter.cjs Widens formatter JSDoc types to accept nullable tool/alternatives values and nullable/undefined text.
actions/setup/js/handle_agent_failure.cjs Removes overly-forcing JSDoc annotations so TypeScript can narrow optional items correctly.
actions/setup/js/aw_context.cjs Fixes JSDoc cast syntax by adding parentheses so the cast is not ignored by TypeScript.

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

Comment on lines 20 to 22
* @param {typeof core} coreModule - The @actions/core module
* @param {typeof github} githubModule - The @actions/github module
* @param {any} githubModule - The @actions/github module
* @param {typeof context} contextModule - The GitHub context object
Comment on lines 21 to 24
/**
* Format missing_tool messages into markdown list items
* @param {Array<{tool: string, reason: string, alternatives?: string}>} missingTools - Missing tool messages
* @param {Array<{tool: string | null, reason: string, alternatives?: string | null}>} missingTools - Missing tool messages
* @returns {string} Formatted markdown list
@github-actions github-actions Bot mentioned this pull request May 3, 2026
Copilot AI added a commit that referenced this pull request May 3, 2026
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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