Skip to content

preferences: Convert the package to TypeScript#71915

Merged
manzoorwanijk merged 20 commits intoWordPress:trunkfrom
joshualip-plaudit:convert-preferences-to-ts
Oct 29, 2025
Merged

preferences: Convert the package to TypeScript#71915
manzoorwanijk merged 20 commits intoWordPress:trunkfrom
joshualip-plaudit:convert-preferences-to-ts

Conversation

@joshualip-plaudit
Copy link
Contributor

What?

Closes #71913

This is a direct conversion of the Preferences package to TypeScript. None of the functionality has been modified - it just emits typedefs now.

Why?

I want to be able to convert the Block Editor package to TypeScript. The Preferences package is one that it depends on, so it seemed like a good place to start.

How?

I made a direct conversion of the package to TypeScript. This boiled down to swapping out the extensions and some minor tweaks to the typedefs.

I did also have to make a minor modification to the Components package (the CardHeader component was missing some props)

Testing Instructions

Everything should be covered by existing build-time tests.

@github-actions
Copy link

github-actions bot commented Sep 26, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: joshualip-plaudit <[email protected]>
Co-authored-by: manzoorwanijk <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: t-hamano <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 26, 2025
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @joshualip-plaudit! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Package] Preferences /packages/preferences labels Sep 26, 2025
@joshualip-plaudit
Copy link
Contributor Author

I don't know how to add the "props-bot" label, but I linked my account

@joshualip-plaudit
Copy link
Contributor Author

So... Tests failed because they timed out while downloading themes. How do I go about restarting them?

@t-hamano t-hamano mentioned this pull request Sep 27, 2025
40 tasks
Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. I have some suggestions for further improvements and some ideas about preserving git history for some files.

@manzoorwanijk manzoorwanijk changed the title Converting the preferences package to TypeScript preferences: Convert the package to TypeScript Sep 30, 2025
@joshualip-plaudit
Copy link
Contributor Author

joshualip-plaudit commented Sep 30, 2025

@manzoorwanijk I'll make the changes that you requested to try to fix the git history later today (although, I don't know if that's going to be recoverable without me remaking the branch + changes from scratch).

Wrt to the "replace react imports with React.ReactNode" suggestions, I'm curious as to how switching from a type import to React.ReactNode changes anything? React is still being "imported" (in quotes because it's not the same import process as an import statement), but now we're relying on an implicit "import" of a global namespace.

Update: Fixing the history loss is done. I wound up recreating the branch and separating the rename and edit steps for the files that had issues into two commits

@joshualip-plaudit
Copy link
Contributor Author

@manzoorwanijk Ping on this one? I'm unsure what you mean by, "move this to an inline types.ts file". I was able to resolve the history issue without relying on an external file, so I don't think it's needed anymore.

Also, I am still curious why using React.ReactNode is preferred over using a typed import. If it's a style thing, I can change it, I'm just wondering if there is an additional concern because I use that import style in my own projects.

@manzoorwanijk
Copy link
Member

why using React.ReactNode is preferred over using a typed import.

Since React is available globally, it saves us an import statement when used instead of using the type import.

@joshualip-plaudit
Copy link
Contributor Author

Thanks for the clarification! I've made the requested changes.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This looks good. I just have a couple of questions about maybe not enforcing certain things.

@swissspidy
Copy link
Member

Nice, this will make #64799 obsolete

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This looks good to ship now. Let us update it from trunk and fix the merge conflicts.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Let us ship it. Thank you for your contribution.

@manzoorwanijk manzoorwanijk merged commit a7b00a5 into WordPress:trunk Oct 29, 2025
35 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.0 milestone Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Preferences /packages/preferences [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert the Preferences package to TypeScript

4 participants