Skip to content

Try type gurads#608

Merged
subdavis merged 2 commits into
client/attributes-updatefrom
client/attributes-update-brandon
Mar 2, 2021
Merged

Try type gurads#608
subdavis merged 2 commits into
client/attributes-updatefrom
client/attributes-update-brandon

Conversation

@subdavis
Copy link
Copy Markdown
Contributor

@subdavis subdavis commented Mar 1, 2021

Bryon, I saw your comment and it looked like this might be a good use of type guards.

I haven't tested this, I'm not even 100% sure this is a good solution. I'm more just interested in if you think this is better style or provides more safety.

Risks to this change:

  • Updating the interface but forgetting to update the guard. They're defined next to each other, so hopefully this is mitigated.
  • Doesn't place enough trust in the type system. (similar to above)
  • Too generic, hurts readability.

LMK what you think.

@subdavis subdavis requested a review from BryonLewis March 1, 2021 21:58
@BryonLewis
Copy link
Copy Markdown
Collaborator

I'll do a more in-depth review tomorrow morning but this looks similar to what I was thinking but I was a bit too lazy to look into implementation.

The one thing that still feel weird with the type guards is that it seems like you're double declaring the type. I wish there was a better way to do it while utilizing the existing type.

Only other additional thing I think is that the types and functions for markChangesPending in useTypeStyling and useAttributes need to be modified. The types were set to strictly be what they needed in each of the files.

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

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

I like this a lot better than my code duplication.

@subdavis subdavis merged commit f144e49 into client/attributes-update Mar 2, 2021
@subdavis subdavis deleted the client/attributes-update-brandon branch March 2, 2021 13:36
BryonLewis added a commit that referenced this pull request Mar 3, 2021
* useAttributes base

* fixing web version

* Updating backend and fixing some metadata issues

* mend

* adressing my own review

* Try type gurads (#608)

* Try type gurads

* markChangesPending update (#609)

Co-authored-by: BryonLewis <61746913+BryonLewis@users.noreply.github.com>

* linting fixes

* Addressing comments, fixing desktop

Co-authored-by: Brandon Davis <brandon.davis@kitware.com>
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