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

Fixed incorrect type annotations in @wordpress/data #46881

Merged
merged 3 commits into from
Feb 7, 2023
Merged

Fixed incorrect type annotations in @wordpress/data #46881

merged 3 commits into from
Feb 7, 2023

Conversation

marekdedic
Copy link
Contributor

What?

This PR modifies several type annotations in the data package so that they don't throw errors when used in a TS codebase. The errors are mainly due to type constraints not being satisfied in templated types.

This PR fixes #46626.

How?

Mostly I just added the needed type constraints to the affected type annotations. In the case of the select() and dispatch() functions, I added a new @type annotation, but I am not sure whether to remove the (now redundant) @param and @return annotations.

Testing Instructions

  1. Check out https://github.com/marekdedic/DefinitelyTyped/tree/wordpress__rich-text-upstream-data
  2. Delete the types/wordpress__data directory to force use of types in @wordpress/data
  3. Run npm test wordpress__rich-text
  4. You should see no error with this PR, as opposed to trunk

Important notice

I have not been able to test this PR directly due to #46652. I have manually modified the built types to fix the issue and then applied the fixes from the build artifacts to the source code. Could you please test this before merging?

@marekdedic marekdedic requested a review from nerrad as a code owner January 4, 2023 11:36
@skorasaurus skorasaurus added [Package] Data /packages/data [Type] Code Quality Issues or PRs that relate to code quality labels Jan 9, 2023
@gziolo gziolo requested review from adamziel and dmsnell February 5, 2023 06:13
Copy link
Member

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

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

Looks fine to me. I didn't verify any of this, but it looks like it only enhances the types where they are currently too wide. Thanks for the submission!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Data /packages/data [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type errors in @wordpress/data
4 participants