fix: resolve TypeScript typecheck errors in JS files#30026
Merged
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7e607dd2-785d-4dfc-be95-28965b571224 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pelikhan
May 3, 2026 22:56
View session
Contributor
There was a problem hiding this comment.
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.cjsso TypeScript applies the intendedRecord<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 |
Copilot AI
added a commit
that referenced
this pull request
May 3, 2026
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
js-typecheckCI 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 seesobjectinstead ofRecord<string, unknown>handle_agent_failure.cjs: Remove erroneous/** @type {Array<any>} */annotations onresolvedItems— the optionalitemsparam isArray<any> | undefined, conflicting with the forcedArray<any>annotation; TypeScript narrows correctly after the null-check/early-return block without the annotationhandle_agent_failure.cjs+missing_info_formatter.cjs: WidenformatMissingToolsandescapeMarkdownparameter types to acceptstring | null, matching the actual return type ofloadMissingToolMessages(toolfield isstring | null)pick_experiment.cjs: Addms != null &&guard beforems > 0(TypeScript doesn't narrow throughNumber.isInteger); use?? 0fallback forminSamplessince the outerprogressNamesfilter already guarantees it's a positive integersetup_globals.cjs: Change@param {typeof github}to@param {any}—typeof githubcreated a TS2502 circular self-reference because TypeScript was inferring the globalgithubtype through theglobal.github = createRateLimitAwareGithub(githubModule)assignment in the same function