Skip to content

iAPI: Make storePart argument optional in overloads #70296

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

Merged
merged 4 commits into from
Jun 3, 2025

Conversation

DAreRodz
Copy link
Contributor

@DAreRodz DAreRodz commented Jun 3, 2025

What?

Fixes store() types to support typing it without passing a store part. E.g.,

import { store } from '@wordpress/interactivity';

const otherStore = store<OtherStoreTypes>( 'other-store' );

Props to @luisherranz.

Why?

Developers could want to use store to get the state and actions of an external store. In that case, they don't need to pass any store part. We forgot to include this case in the improvements we made in #64577.

How?

Simply making storePart optional when passing the full types.

The PR includes TypeScript tests.

@DAreRodz DAreRodz requested a review from SantosGuillamot June 3, 2025 09:10
@DAreRodz DAreRodz requested a review from luisherranz as a code owner June 3, 2025 09:10
Copy link

github-actions bot commented Jun 3, 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: luisherranz <luisherranz@git.wordpress.org>

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

@DAreRodz DAreRodz added [Type] Bug An existing feature does not function as intended [Feature] Interactivity API API to add frontend interactivity to blocks. [Packages] Interactivity /packages/interactivity labels Jun 3, 2025
Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

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

LGTM!

@DAreRodz DAreRodz merged commit a5e3592 into trunk Jun 3, 2025
68 of 70 checks passed
@DAreRodz DAreRodz deleted the iapi-allow-typed-store-to-miss-the-store-part branch June 3, 2025 11:51
@github-actions github-actions bot added this to the Gutenberg 21.0 milestone Jun 3, 2025
@luisherranz
Copy link
Member

Oh, we forgot to add an entry to the changelog.

chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
* Make storePart argument optional in overloads

* Trigger actions

* Fix test (types)

* Fix test again (types)

---------

Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Interactivity API API to add frontend interactivity to blocks. [Packages] Interactivity /packages/interactivity [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants