Fix TypeScript build error from @wordpress/api-fetch 7.36.0 upgrade#3876
Fix TypeScript build error from @wordpress/api-fetch 7.36.0 upgrade#3876
Conversation
📝 WalkthroughWalkthroughThe pull request updates the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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 unwrapsresponse.data), but the JSDoc saysPromise<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
📒 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 toAPIFetchOptions<true>looks correct and removes the need for casting.Updating the parameter to
APIFetchOptions<true>and passing it directly toapiFetch<ContentHelperAPIResponse<T>>aligns the signature with the upgraded@wordpress/api-fetchtypes 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
Description
Fixes TypeScript type mismatch in
base-provider.tsxafter@wordpress/api-fetchwas upgraded from 7.29.0 to 7.36.0 in #3857.The new version introduced stricter generics on
APIFetchOptions<Parse>(defaults toboolean), butapiFetch()expectsAPIFetchOptions<true>. Updated thefetchmethod signature to use the correct type parameter:Motivation and context
Build failures on
developbranch after merging #3857:How has this been tested?
npm run buildpassesnpm run lint:jspassesnpm run test:unitpasses (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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/mkkxIx /usr/bin/composer install(http block)/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/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/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/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/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/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/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/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/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
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.