-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Convert api-fetch package to TypeScript #67669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -2 B (0%) Total Size: 1.91 MB
ℹ️ View Unchanged
|
Flaky tests detected in 5274343. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/16641709143
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR converts the api-fetch package to TypeScript while improving type definitions and updating corresponding unit tests. Key changes include converting JS files to TS with explicit type annotations, enhancing API fetch types based on the parse option, and updating test files with async FetchHandler type declarations.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/api-fetch/src/middlewares/user-locale.ts | Converted to TS with added import type and updated JSDoc. |
packages/api-fetch/src/middlewares/theme-preview.ts | New TS implementation with type annotations. |
packages/api-fetch/src/middlewares/theme-preview.js | Removed as part of the conversion. |
packages/api-fetch/src/middlewares/test/* | Updated test files (user-locale, root-url, preloading, nonce, namespace-endpoint, media-upload, http-v1, fetch-all-middleware) to use async FetchHandler types. |
packages/api-fetch/src/middlewares/root-url.ts | Converted to TS with updated URL handling. |
packages/api-fetch/src/middlewares/preloading.ts | Added TS types and refined prepareResponse function. |
packages/api-fetch/src/middlewares/nonce.ts | Converted to TS and improved middleware type signatures. |
packages/api-fetch/src/middlewares/namespace-endpoint.ts | Updated middleware to TS with explicit type declarations. |
packages/api-fetch/src/middlewares/media-upload.ts | Converted to TS with proper type definitions for request options and middleware logic. |
packages/api-fetch/src/middlewares/http-v1.ts | Converted to TS with updated override logic and type safety. |
packages/api-fetch/src/middlewares/fetch-all-middleware.ts | Updated to TS with improved type annotations and proper import changes. |
packages/api-fetch/src/index.ts | Main entry point converted to TS with enhanced type definitions and middleware chaining logic. |
Supercedes #67510, which got closed after I deleted my fork 🤦
What?
api-fetch
package to TypeScriptparse
optionWhy?
Improve the DX
and fix an issue when used in ES ModulesHow?
By renaming the files and updating types
Testing Instructions