-
Notifications
You must be signed in to change notification settings - Fork 9
Make selectedReferences undefined if referenceIdentifierField is undefined #5899
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
Conversation
|
This PR appears to address #5891 by making |
| setSelectedReferences={setSelectedReferences} | ||
| /> | ||
| )} | ||
| {referenceIdentifierField !== undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now if referenceIdentifierField is undefined so is the selectedReferences object
|
Claude finished @anna-parker's task in 1m 56s —— View job Code Review CompleteI've reviewed the changes in this PR that make SummaryStrengths:
Areas for consideration:
Type SafetyThe PR successfully makes the types more explicit by:
The pattern of using ternary operators with object spreads to satisfy TypeScript's type narrowing is correct, though somewhat verbose. Code QualityThe changes maintain good defensive programming practices:
TestingTest updates in Minor Issues (see inline comments)I've added inline comments on:
RecommendationThis PR is ready to merge after addressing the inline comments. The changes are type-safe, well-tested, and improve code clarity by making the relationship between |
| setSelectedReferences={setSelectedReferences} | ||
| /> | ||
| )} | ||
| {referenceIdentifierField !== undefined && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good defensive programming! This triple-check ensures all three related values are defined together before rendering the ReferenceSelector. However, TypeScript should guarantee that if referenceIdentifierField is defined, then both selectedReferences and setSelectedReferences are also defined (based on the logic in useSearchPageState.ts). Consider whether this could be simplified to just checking referenceIdentifierField !== undefined with a type assertion, or adding a comment explaining why all three checks are necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... I still think this is kinda ugly
resolves # ### Screenshot ### PR Checklist - [ ] All necessary documentation has been adapted. - [ ] The implemented feature is covered by appropriate, automated tests. - [ ] Any manual testing that has been done is documented (i.e. what exactly was tested?) 🚀 Preview: Add `preview` label to enable
Linked to suggestion from @theosanderson: #5799 (comment) - the selectedReferences object should be undefined in the case where the referenceIdentifierField is undefined
Screenshot
PR Checklist
🚀 Preview: https://updates.loculus.org