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(fe): unify TaggedObject type usage + corresponding refactor #31969

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hainenber
Copy link
Contributor

chore(fe): unify TaggedObject type usage + corresponding refactor

SUMMARY

Part of rectification of existing type errors before TypeScript v5 migration.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before
image
image

After
image

TESTING INSTRUCTIONS

All CI checks should pass

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Signed-off-by: hainenber <dotronghai96@gmail.com>
@dosubot dosubot bot added the frontend:refactor Related to refactoring the frontend label Jan 23, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Fix Detected
Functionality Inconsistent tagIds parameter type ▹ view

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • Chat with Korbit on issues we post by tagging @korbit-ai in your reply.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Feedback and Support

tagIds = [],
types,
}: { tagIds: number[] | undefined; types: string | null },
{ tagIds = [], types }: { tagIds: number[] | string; types: string | null },

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@korbit-ai The fetchObject function in this file also have string type for tagsId so the old behavior is OK

Copy link

Choose a reason for hiding this comment

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

@hainenber Thank you for pointing that out. It makes sense to maintain the original structure if other functions are using the same type. However, for long-term consistency and error reduction, we could consider standardizing the data types used in API parameters across functions. What do you think about gradually refactoring other functions to only accept array of numbers for tagIds as well?

Copy link
Contributor Author

@hainenber hainenber Jan 24, 2025

Choose a reason for hiding this comment

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

@korbit-ai Sure, can we leave it for another PR?

Copy link
Member

Choose a reason for hiding this comment

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

@hainenber I haven't looked at the tagID format(s) - does this feedback make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, turned out the fetchObject function I referred above is not used anywhere 🤦 . No point in using it to defend keeping old behavior.

Okay, Korbot makes sense here. However, since tag?.id in the old code will assume undefined value, I'll change the parameter to accommodate the old behavior as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update in HEAD :D

…function

Signed-off-by: hainenber <dotronghai96@gmail.com>
@@ -152,12 +140,16 @@ function AllEntities() {
return;
}
fetchObjectsByTagIds(
{ tagIds: [tag?.id] || '', types: null },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is always evaluated to truthy so it'll always give out (undefined | number)[]

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend:refactor Related to refactoring the frontend size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants