Skip to content

Fix TypeScript build error from @wordpress/api-fetch 7.36.0 upgrade#3876

Merged
acicovic merged 2 commits intodevelopfrom
copilot/fix-build-errors-in-develop
Nov 28, 2025
Merged

Fix TypeScript build error from @wordpress/api-fetch 7.36.0 upgrade#3876
acicovic merged 2 commits intodevelopfrom
copilot/fix-build-errors-in-develop

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

Description

Fixes TypeScript type mismatch in base-provider.tsx after @wordpress/api-fetch was upgraded from 7.29.0 to 7.36.0 in #3857.

The new version introduced stricter generics on APIFetchOptions<Parse> (defaults to boolean), but apiFetch() expects APIFetchOptions<true>. Updated the fetch method signature to use the correct type parameter:

// Before
protected async fetch<T>( options: APIFetchOptions, id?: string ): Promise<T> {
    const response = await apiFetch<...>( options as APIFetchOptions<true> );

// After  
protected async fetch<T>( options: APIFetchOptions<true>, id?: string ): Promise<T> {
    const response = await apiFetch<...>( options );

Motivation and context

Build failures on develop branch after merging #3857:

How has this been tested?

  • npm run build passes
  • npm run lint:js passes
  • npm run test:unit passes (84 tests)

Screenshots (if appropriate)

N/A

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/AxeWP/wp-graphql-stubs/zipball/6ca5c5ee37012743e09e2f9e7c3c272c5e273bb8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/Masterminds/html5-php/zipball/fcf91eb64359852f00d921887b219479b4f21251
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/b598aa890815b8df16363271b659d73280129101
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/d71128c702c180ca3b27c761b6773f883394f162
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/244d7b04fc4bc2117c15f5abe23eb933b5f02bbf
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/7c8d18b4d90dac9e86b0869a608fa09158e168fa
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/antecedent/patchwork/zipball/8b6b235f405af175259c8f56aea5fc23ab9f03ce
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/composer/installers/zipball/12fb2dfe5e16183de69e784a7b84046c43d97e8e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/hamcrest/hamcrest-php/zipball/f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/php-stubs/wordpress-tests-stubs/zipball/95979e5c671c72350dde78b89e29afdd88c37140
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/mkkxIx /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan-mockery/zipball/98cac6e256b4ee60fdeb26a7dd81bb271b454e80
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/b564ca479e7e735f750aaac4935af965572a7845
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/84Cojp /usr/bin/composer install --prefer-dist --no-progress --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Merging #3857 into our develop branch results in build errors (https://github.com/Parsely/wp-parsely/actions/runs/19773107888/job/56660997095) which aren't present when tests are running in the PR. Can you resolve the issue?


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Summary by CodeRabbit

  • Refactor
    • Enhanced internal type safety and code clarity through improved method signature typing and removal of unnecessary type casting operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

📝 Walkthrough

Walkthrough

The pull request updates the fetch method in BaseProvider to enforce stricter typing by changing the options parameter type from APIFetchOptions to APIFetchOptions<true>. A corresponding type cast is removed from the apiFetch call, and JSDoc formatting is adjusted. No behavioral changes occur.

Changes

Cohort / File(s) Summary
BaseProvider typing refinement
src/content-helper/common/providers/base-provider.tsx
Updated fetch method signature to use APIFetchOptions<true> type; removed runtime type cast from apiFetch call; adjusted JSDoc parameter alignment

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single-file, homogeneous typing refinement with no behavioral changes
  • Simple removal of type cast and parameter type tightening

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a TypeScript build error from a dependency upgrade, which is the core purpose of this PR.
Description check ✅ Passed The description includes all required sections with comprehensive details: problem description, motivation/context with build failure link, testing results, and appropriate N/A for screenshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/fix-build-errors-in-develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@acicovic acicovic marked this pull request as ready for review November 28, 2025 20:36
@acicovic acicovic requested a review from a team as a code owner November 28, 2025 20:36
@acicovic
Copy link
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI changed the title [WIP] Fix build errors after merging PR 3857 into develop Fix TypeScript build error from @wordpress/api-fetch 7.36.0 upgrade Nov 28, 2025
Copilot AI requested a review from acicovic November 28, 2025 20:37
@acicovic acicovic added this to the 3.22.0 milestone Nov 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/content-helper/common/providers/base-provider.tsx (1)

139-145: JSDoc return type is out of sync with the actual return type.

The method returns Promise<T> (it unwraps response.data), but the JSDoc says Promise<ContentHelperAPIResponse<any>>. To avoid confusion, consider updating the JSDoc, e.g.:

 /**
  * Fetches data from the API. Either resolves with the data or rejects with
  * an error.
@@
  *
  * @since 3.15.0
  *
+ * @template T
  * @param {APIFetchOptions<true>} options The options to pass to apiFetch.
  * @param {string?}               id      The (optional) ID of the request.
  *
- * @return {Promise<ContentHelperAPIResponse<any>>} The fetched data.
+ * @return {Promise<T>} The fetched data.
  */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69ce0b0 and e8a1504.

📒 Files selected for processing (1)
  • src/content-helper/common/providers/base-provider.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,jsx}

⚙️ CodeRabbit configuration file

**/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."

Files:

  • src/content-helper/common/providers/base-provider.tsx
🧬 Code graph analysis (1)
src/content-helper/common/providers/base-provider.tsx (1)
src/content-helper/common/providers/base-wordpress-provider.tsx (1)
  • apiFetch (145-189)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: E2E against WordPress latest
🔇 Additional comments (1)
src/content-helper/common/providers/base-provider.tsx (1)

141-142: Type tightening to APIFetchOptions<true> looks correct and removes the need for casting.

Updating the parameter to APIFetchOptions<true> and passing it directly to apiFetch<ContentHelperAPIResponse<T>> aligns the signature with the upgraded @wordpress/api-fetch types and should resolve the previous mismatch without changing runtime behavior. Please just confirm all call sites pass options compatible with a parsed (parse: true / default) response.

Also applies to: 146-152

@acicovic acicovic merged commit 3de1f7c into develop Nov 28, 2025
36 of 55 checks passed
@acicovic acicovic deleted the copilot/fix-build-errors-in-develop branch November 28, 2025 20:42
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