Skip to content

More label fixes#366

Merged
floryst merged 2 commits intomainfrom
more-label-fixes
Jul 13, 2023
Merged

More label fixes#366
floryst merged 2 commits intomainfrom
more-label-fixes

Conversation

@floryst
Copy link
Contributor

@floryst floryst commented Jul 12, 2023

Fixes the types passed into useLabels.

@floryst floryst requested a review from PaulHax July 12, 2023 17:18
@netlify
Copy link

netlify bot commented Jul 12, 2023

Deploy Preview for volview-dev ready!

Name Link
🔨 Latest commit 5cf8007
🔍 Latest deploy log https://app.netlify.com/sites/volview-dev/deploys/64aee05346f3bb0008c02253
😎 Deploy Preview https://deploy-preview-366--volview-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@PaulHax PaulHax left a comment

Choose a reason for hiding this comment

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

We lost some type safety with the MakeToolDefaults extends (...args: any) => any change earlier. Before, ToolDefaults and label properties needed to exist in the Ruler or Rectangle type.

Would be nice if we got a Typescript error if default label properties did not exist on tool. Then a object of type Label<Tool> could not have arbitrary properties.

@floryst
Copy link
Contributor Author

floryst commented Jul 13, 2023

I'm not sure if we've lost type safety. We have type ToolDefaults = ReturnType<MakeToolDefaults>, which infers the return type of the passed-in toolDefaults function.

I find Label<Tool> to be misleading. A label doesn't need to follow the Tool & AnnotationTool type. AFAIK it should be { labelName: string } & typeof newLabelDefault. I was seeing toolStore.labels[labelId] contain properties from AnnotationTool, which seems incorrect.

If there's something design-wise that I missed, do let me know.

@PaulHax PaulHax self-requested a review July 13, 2023 17:50
Copy link
Collaborator

@PaulHax PaulHax left a comment

Choose a reason for hiding this comment

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

Ah, I see, thanks for the learning.

@floryst floryst merged commit b1275ef into main Jul 13, 2023
@floryst floryst deleted the more-label-fixes branch July 13, 2023 19:31
PaulHax pushed a commit to PaulHax/VolView that referenced this pull request Apr 24, 2025
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