close
Skip to content

blocks: Port over some of the type information for @wordpress/blocks from DefinitelyTyped#77393

Merged
manzoorwanijk merged 1 commit into
WordPress:trunkfrom
joshualip-plaudit:update/blocks/port-definitely-typed-generics
Apr 16, 2026
Merged

blocks: Port over some of the type information for @wordpress/blocks from DefinitelyTyped#77393
manzoorwanijk merged 1 commit into
WordPress:trunkfrom
joshualip-plaudit:update/blocks/port-definitely-typed-generics

Conversation

@joshualip-plaudit
Copy link
Copy Markdown
Contributor

What?

Closes #77390

This PR adds in the generics that were missing and patches up some differences between the types added in #76312 and the underlying code. It also includes a couple of spots where I patched up mismatches between the types and the underlying logic of the select and dispatch calls in the process of porting over the types.

Why?

This PR fixes issues introduced by the differences between the types added in #76312 and the DefinitelyTyped version.

How?

I ported over the original typedefs where useful and tweaked the ones that didn't match. I didn't rename any of the new types, so there will still be compatibility issues in some cases, but those are fixable via a quick find-and-replace, so I didn't think that the added changes in this PR would be worth it

Testing Instructions

  1. Build the project
  2. Try building something that previously relied on @types/wordpress__blocks with the built types
    • You may need to do some substitutions for the updated type names, but the key part is the generics

@github-actions github-actions Bot added the [Package] Blocks /packages/blocks label Apr 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 15, 2026

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 <joshualipstone@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>

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

@Mamaduka Mamaduka requested a review from manzoorwanijk April 16, 2026 05:15
@manzoorwanijk manzoorwanijk requested review from aduth and jsnajdr April 16, 2026 05:18
@manzoorwanijk
Copy link
Copy Markdown
Member

I’m travelling for the next couple of days. I’ll get back to this next week if nobody beats me to it.

@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Apr 16, 2026
@manzoorwanijk manzoorwanijk changed the title Ported over some of the type information for @wordpress/blocks from DefinitelyTyped blocks: Port over some of the type information for @wordpress/blocks from DefinitelyTyped Apr 16, 2026
Copy link
Copy Markdown
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 me. I just have a suggestion for improved changelog entry.

Comment thread packages/blocks/CHANGELOG.md
@manzoorwanijk
Copy link
Copy Markdown
Member

Meanwhile, I have created a PR to get rid of some @types/* packages, including the blocks package - DefinitelyTyped/DefinitelyTyped#74886

@manzoorwanijk manzoorwanijk merged commit 4aa6e96 into WordPress:trunk Apr 16, 2026
46 of 50 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 16, 2026
Comment thread packages/blocks/README.md

### registerBlockType

Registers a new block provided a unique name and an object defining its behavior. Once registered, the block is made available as an option to any editor interface where blocks are implemented.
Copy link
Copy Markdown
Member

@aduth aduth Apr 16, 2026

Choose a reason for hiding this comment

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

It's unfortunate we lost this documentation, as it's one of the most important APIs in the block editor and I would fully expect people would be frequently referencing its API documentation through the developer site.

I'm guessing this is a case where the auto-documentation tool isn't able to handle function overloads we're adding, and the solution would be to improve the auto-documenter to handle those better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm guessing this is a case where the auto-documentation tool isn't able to handle function overloads we're adding, and the solution would be to improve the auto-documenter to handle those better?

Yes, the tool needs some improvement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Created an issue at #77457

ciampo pushed a commit that referenced this pull request Apr 16, 2026
…from DefinitelyTyped (#77393)

Co-authored-by: joshualip-plaudit <joshualipstone@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
@joshualip-plaudit joshualip-plaudit deleted the update/blocks/port-definitely-typed-generics branch April 16, 2026 19:40
@joshualip-plaudit
Copy link
Copy Markdown
Contributor Author

joshualip-plaudit commented Apr 16, 2026

@manzoorwanijk / @aduth
Do either of you know when this will get published to npm? I'd prefer to have the generics available in @wordpress/blocks before approving DefinitelyTyped/DefinitelyTyped#74886, but I also don't want to leave it sitting.

@manzoorwanijk
Copy link
Copy Markdown
Member

I'd prefer to have the generics available in @wordpress/blocks before approving DefinitelyTyped/DefinitelyTyped#74886, but I also don't want to leave it sitting.

Previous versions of @types/wordpress__blocks should continue working.

@joshualip-plaudit
Copy link
Copy Markdown
Contributor Author

joshualip-plaudit commented Apr 17, 2026

I'd prefer to have the generics available in @wordpress/blocks before approving DefinitelyTyped/DefinitelyTyped#74886, but I also don't want to leave it sitting.

Previous versions of @types/wordpress__blocks should continue working.

@manzoorwanijk The problem is that all of these changes have been going out as minor version updates (i.e. "15.16.0 -> 15.17.0" instead of "15.16.0 -> 16.0.0"), which means that even if I pin everything in my root package.json file, the updated (and incompatible) versions get downloaded because every pinned package that I have is using "^15.16.0" for @wordpress/blocks. I've spent a solid 12 hours dealing with infrastructure issues because the build process keeps breaking for sites and plugins during routine updates, and I'm likely going to have another good chunk of a day either removing the hacks I put into place or formalizing them so that I'll have ready access to a company-wide off-switch for updates if this happens again.

@joshualip-plaudit
Copy link
Copy Markdown
Contributor Author

I'd prefer to have the generics available in @wordpress/blocks before approving DefinitelyTyped/DefinitelyTyped#74886, but I also don't want to leave it sitting.

Previous versions of @types/wordpress__blocks should continue working.

@manzoorwanijk Yep. Called it. All of your changes in DefinitelyTyped/DefinitelyTyped#74886 got deployed as minor versions, which broke the processes I mentioned again.

@joshualip-plaudit
Copy link
Copy Markdown
Contributor Author

joshualip-plaudit commented Apr 23, 2026

@manzoorwanijk / @aduth Any idea when this is going to get published? I'm using PNPM's overrides for now, but it's been over a week.

@aduth
Copy link
Copy Markdown
Member

aduth commented Apr 23, 2026

You might be able to use the @next tag which was published 3 days ago. @latest is published with the plugin release schedule (every 2 weeks), and the last was 8 days ago, so probably about another week.

@joshualip-plaudit
Copy link
Copy Markdown
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Blocks /packages/blocks [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The new types in @wordpress/blocks don't have the generics that the @types/wordpress__blocks package did

3 participants