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 the ReactionSpec type fix #3540

Merged
merged 2 commits into from
Dec 1, 2023
Merged

Fixed the ReactionSpec type fix #3540

merged 2 commits into from
Dec 1, 2023

Conversation

jskupsik
Copy link
Contributor

@jskupsik jskupsik commented Nov 28, 2023

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

@jskupsik
Copy link
Contributor Author

jskupsik commented Nov 28, 2023

My original PR ended up not changing the ReactionSpec.equals type.

The derived type ended up being IEqualsComparer<T> & (keyof typeof comparer | IEqualsComparer<T>) which simplifies down to IEqualsComparer<T> - which is exactly what it was before my change.

The issue is that ReactionSpec does not extend IReactionOptions in the typescript sense. The fact that it accepts values for equals that IReactionOptions does not accept breaks inheritance- a ReactionSpec may not work if used as a IReactionOptions. We understand that and use the private parseReactionOptions() function to convert the ReactionSpec to IReactionOptions.

The type needs to be more explicit about this lack of inheritance - "ReactionSpec is mostly of type 'IReactionOptions' EXCEPT for the 'equals' property, which we override and then handle ourselves."

@lbwexler
Copy link
Member

lbwexler commented Dec 1, 2023

So interesting -- I almost suggested the use of omit for the last go around, but had thought in my research that the & would override the type. In any case, looks good to me. I would probably make this interface rather than a type

@jskupsik jskupsik marked this pull request as ready for review December 1, 2023 16:25
@lbwexler lbwexler merged commit 5a729ef into develop Dec 1, 2023
@lbwexler lbwexler deleted the reactionSpecEqualsType2 branch December 1, 2023 16:33
@amcclain amcclain changed the title Fixed the ReactionSpec type fix Fixed the ReactionSpec type fix Dec 11, 2023
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.

2 participants