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

chore(devex) Add types for renameProps helper #607

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

Dominik-Petrik
Copy link
Contributor

Towards #573

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

Awesome work 🚀

I've got a good amount of comments here, but many are just general refactor things that I'm absolutely fine with being a followup.

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman 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 looking GREAT 🔥 🔥 🔥, just a few more small things

propRename: RenameConfig | string | Record<PropertyKey, never>,
defaultMessage: string
) => {
if (!(isRenameConfig(propRename) && propRename.message))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: IMO it's really easy to misread a notted multi conditional like this and think the logic is actually !isRenameConfig(propRename) && propRename.message, I would not both expressions.

Suggested change
if (!(isRenameConfig(propRename) && propRename.message))
if (!isRenameConfig(propRename) && !propRename.message)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be wrong but these two statements are not equal, are they? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if (!isRenameConfig(propRename) || !propRename.message) is the right one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And Record<PropertyKey, never> should be a correct way to type an empty object {}, which can be passed as a shorthand for removing a prop.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shoot I totally missed these messages, my bad. And yep you're right about the logic!

For the Record type TIL about empty object types, thanks for linking that! I do question the API a bit here, using an empty object for prop removal feels a bit odd for me, but that's something we can discuss later.

Copy link
Collaborator

@wise-king-sullyman wise-king-sullyman left a comment

Choose a reason for hiding this comment

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

🚀 🚀 🚀 B E A U T I F U L 🚀 🚀 🚀

@thatblindgeye thatblindgeye merged commit 113caaa into patternfly:main Apr 23, 2024
3 checks passed
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.

Type renameProps and findAncestor helpers
3 participants