Skip to content

Fix core.warn API usage and enable comprehensive type checking for JavaScript files#768

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-a7515245-bebc-4927-8067-06a6122ec497
Sep 12, 2025
Merged

Fix core.warn API usage and enable comprehensive type checking for JavaScript files#768
pelikhan merged 3 commits intomainfrom
copilot/fix-a7515245-bebc-4927-8067-06a6122ec497

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 12, 2025

The TypeScript type checking system was not properly validating core.* API usage in JavaScript .cjs files, allowing invalid method calls like core.warn() to pass undetected.

Problem

Several JavaScript files were using core.warn(), which doesn't exist in the @actions/core library. The correct method is core.warning(). Additionally, many .cjs files were not included in the TypeScript configuration, meaning type errors went undetected.

For example, this invalid code was not being caught:

// This should fail type checking but didn't
core.warn("This method doesn't exist");

Solution

  1. Fixed invalid API usage: Replaced all instances of core.warn() with the correct core.warning() method
  2. Expanded type checking coverage: Added 12 additional .cjs files to tsconfig.json that were previously not being type-checked
  3. Updated test expectations: Modified test files to expect the correct core.warning method instead of the invalid core.warn

Files Changed

  • pkg/workflow/js/add_reaction_and_edit_comment.cjs - Fixed core.warn() calls
  • pkg/workflow/js/validate_errors.cjs - Fixed core.warn() usage
  • pkg/workflow/js/validate_errors.test.cjs - Updated test mocks and expectations
  • tsconfig.json - Added comprehensive list of .cjs files for type checking

Verification

The type checking system now properly catches invalid core.* API usage:

# This will now fail type checking as expected
npm run typecheck
# error TS2339: Property 'warn' does not exist on type 'typeof import("@actions/core")'

All JavaScript tests continue to pass (324 tests), confirming the fixes work correctly while maintaining existing functionality.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Make sure the type checking of "core.*" APIs is working in JavaScript .cjs files. For example, some files use "core.warn" function which is not a valid function and should trigger a type check error Fix core.warn API usage and enable comprehensive type checking for JavaScript files Sep 12, 2025
Copilot AI requested a review from pelikhan September 12, 2025 13:49
@pelikhan pelikhan marked this pull request as ready for review September 12, 2025 13:53
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge origin/main . The only interesting changes are in the .cjs file. Take all the other changes from the upstream

@pelikhan pelikhan merged commit 077be20 into main Sep 12, 2025
11 of 16 checks passed
@pelikhan pelikhan deleted the copilot/fix-a7515245-bebc-4927-8067-06a6122ec497 branch September 12, 2025 14:30
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.

2 participants