Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion actions/setup/js/upload_assets.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const { loadAgentOutput } = require("./load_agent_output.cjs");
const { getErrorMessage } = require("./error_helpers.cjs");
const { ERR_API, ERR_CONFIG, ERR_SYSTEM, ERR_VALIDATION } = require("./error_codes.cjs");

/**
* @typedef {{ type: string, fileName: string, sha: string, size: number, targetFileName: string, url?: string }} UploadAssetItem
*/

/**
* Normalizes a branch name to be a valid git branch name.
*
Expand Down Expand Up @@ -75,7 +79,7 @@ async function main() {
}

// Find all upload-asset items
const uploadItems = result.items.filter(/** @param {any} item */ item => item.type === "upload_asset");
const uploadItems = /** @type {UploadAssetItem[]} */ result.items.filter(item => item.type === "upload_asset");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

JSDoc type assertion requires parentheses around the expression: TypeScript JSDoc mandates /** @type {T} */ (expr) with parens. Without them, TypeScript treats @type as a variable annotation on uploadItems (silencing inference) rather than a checked cast that validates result.items.filter(...) is actually assignable to UploadAssetItem[]. The file is // @ts-check``, so the distinction matters.

💡 Suggested fix
const uploadItems = /** `@type` {UploadAssetItem[]} */ (result.items.filter(item => item.type === "upload_asset"));

The parenthesized form is the only form TypeScript recognises as a proper type assertion in JSDoc; see the [TypeScript JSDoc reference]((www.typescriptlang.org/redacted)


if (uploadItems.length === 0) {
core.info("No upload-asset items found in agent output");
Expand Down
Loading
Loading