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

Improve "expected error" types #207

Merged
merged 4 commits into from
Nov 20, 2024
Merged

Conversation

chriszarate
Copy link
Member

  • In special circumstances where we are faced with insufficient library types that we cannot augment, we should still work to preserve type safety. Instead of ignoring type errors and effectively relaxing to an any type, we can cordon the problematic entity and reexport it with strict typing. In this PR, we do this for registerBlockBindingsSource.
  • Miscellaneous fixes:
    • Remove redundant export keywords in type declarations.
    • Move NullableKeys utility type to its own file.

} from '@wordpress/block-editor';

interface GetValuesPayload< Context, Values > {
bindings: Values;
Copy link
Member Author

Choose a reason for hiding this comment

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

this probably isn't right, but not sure what it should be. we can improve these once we start to use them

Copy link
Contributor

@alecgeatches alecgeatches left a comment

Choose a reason for hiding this comment

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

Great solution to the problem for now! I like that you've isolated the type-ignores to a file and wrapped with better types.

Copy link
Contributor

@maxschmeling maxschmeling left a comment

Choose a reason for hiding this comment

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

This is a good solution for now. I'd like for us to also try to get these types into the DefinitelyTyped repo so we don't have to have it in our codebase.

@chriszarate chriszarate merged commit 07b2146 into trunk Nov 20, 2024
10 checks passed
@chriszarate chriszarate deleted the improve/expected-error-types branch November 20, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants