Skip to content

Fix js-typecheck regression in parseAwContext object field access#32112

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-typecheck
May 14, 2026
Merged

Fix js-typecheck regression in parseAwContext object field access#32112
pelikhan merged 4 commits into
mainfrom
copilot/fix-typecheck

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

Bug Fix

The js-typecheck job failed in push_to_pull_request_branch.cjs because item_type/item_number were read directly from a value narrowed only to object. TypeScript correctly rejected those property reads.

  • What was the bug?

    • validateAndNormalizeParsedContext accessed parsedObj.item_type and parsedObj.item_number after an object guard, which is not sufficient for typed property access under @ts-check.
    • This caused TS2339 errors in CI (Property ... does not exist on type 'object').
  • How did you fix it?

    • Replaced direct property reads with Reflect.get to read keys from an unknown object safely while preserving runtime behavior.
    • Kept existing normalization semantics:
      • item_type must be a string, otherwise ""
      • item_number is parsed via existing parsePositiveInteger path
const itemTypeValue = Reflect.get(parsed, "item_type");
const itemNumberValue = Reflect.get(parsed, "item_number");
const itemType = typeof itemTypeValue === "string" ? itemTypeValue : "";
const itemNumber = parsePositiveInteger(itemNumberValue);
  • Testing

    • actions/setup/js typecheck path is now clean for this file (the failing TS2339 errors are removed).

Copilot AI and others added 2 commits May 14, 2026 05:35
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review May 14, 2026 12:34
Copilot AI review requested due to automatic review settings May 14, 2026 12:34
const parsedObj = /** @type {Record<string, unknown>} */ parsed;
const itemType = typeof parsedObj.item_type === "string" ? parsedObj.item_type : "";
const itemNumber = parsePositiveInteger(parsedObj.item_number);
const itemTypeValue = Reflect.get(parsed, "item_type");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot keep it simple, do not use reflect

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.

Updated in a2ca378. I removed Reflect.get and switched to a simple typed object cast with direct field access in parseAwContext.

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 a js-typecheck regression in parseAwContext by avoiding direct property access on values narrowed only to object under @ts-check.

Changes:

  • Replace direct reads of item_type / item_number from a loosely-narrowed object with Reflect.get.
  • Preserve existing normalization behavior for item_type (string or "") and item_number (via parsePositiveInteger).
Show a summary per file
File Description
actions/setup/js/push_to_pull_request_branch.cjs Updates parseAwContext normalization to avoid TS2339 property-access errors under @ts-check.

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 +62 to +63
const itemTypeValue = Reflect.get(parsed, "item_type");
const itemNumberValue = Reflect.get(parsed, "item_number");
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Copy Markdown
Collaborator

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 14, 2026

@copilot review all comments

Reviewed all comments and updated the implementation in 90b3903 to use Record<string, unknown> with bracket access for item_type/item_number (no Reflect.get).

@pelikhan pelikhan merged commit 6d89dae into main May 14, 2026
1 check failed
@pelikhan pelikhan deleted the copilot/fix-typecheck branch May 14, 2026 12:52
Copilot stopped work on behalf of pelikhan due to an error May 14, 2026 12:53
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