Skip to content
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

feature(data): add types to dispatch and select #49930

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

johnhooks
Copy link
Contributor

@johnhooks johnhooks commented Apr 19, 2023

What?

Add TypeScript types to dispatch and select of @wordpress/data.

Why?

I and others are using these function with custom stores and would like to use them fully typed. I am currently hacking the type system to accomplish this in the wp-feature-notifications project, but it would be better if these were typed correctly.

How?

I moved the functions to individual TypeScript files because I couldn't provide the correct generic arguments in the index.js file like in useSelect because the types would be exports from packages with the generic arguments. Moving them to a separate file solved this issue, I made them individual files because it seemed appropriate.

@swissspidy @adamziel @dmsnell

Issues

The automatically built docs don't appropriately show the generic type arguments.

@johnhooks johnhooks requested a review from nerrad as a code owner April 19, 2023 18:57
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 19, 2023
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @johnhooks! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

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

@swissspidy
Copy link
Member

Awesome, thank you! I‘ll give this a try as soon as I am back from vacation.

I think after this, thunks are the remaining main thing still without proper types.

@swissspidy
Copy link
Member

This seems to work well in my project 👍

@johnhooks
Copy link
Contributor Author

@swissspidy that's awesome. This is my very first PR to Gutenberg that has had an "approved" review! I'm really new to this, what is the next step?

@swissspidy
Copy link
Member

Normally I would just merge the PR, but since I am not super familiar with the data package and its types, it would be great to wait for another review, ideally by a code owner.

Copy link
Contributor

@adamziel adamziel left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@adamziel adamziel merged commit 61bbcd0 into WordPress:trunk Apr 26, 2023
@github-actions github-actions bot added this to the Gutenberg 15.8 milestone Apr 26, 2023
@johnhooks
Copy link
Contributor Author

I'm so pumped, my first ever PR merged into Gutenberg 🎉

@adamziel adamziel added [Package] Data /packages/data Developer Experience Ideas about improving block and theme developer experience labels Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Data /packages/data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants