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

fix(accounts-controller): export * in index #5224

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Jan 30, 2025

Explanation

Each exports were done manually, which is quite error-prone IMO.

Looks like some other controllers already uses export * from ..., so I believe this will make our exports a bit more future-proof.

Also, if any functions/constants should not be part of the public API, we could use another folder like details or internal and put those files there.

References

N/A

Changelog

@metamask/accounts-controller

  • CHANGED: Properly exports everything

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@mcmire
Copy link
Contributor

mcmire commented Jan 30, 2025

@ccharly Can you explain what you mean by error-prone? Is it just that sometimes we forget to add exports?

If I may offer a counterargument... Listing each import IMO makes it super easy to know at a glance what the package is exporting when it comes time to update the changelog. When using a *, this is now really difficult, and PRs must be checked much more meticulously to make sure that new exports aren't getting added accidentally.

@danroc danroc changed the title fix(accounts-controller): export * in index fix(accounts-controller): export * in index Jan 31, 2025
@danroc
Copy link
Contributor

danroc commented Jan 31, 2025

IMO, we should define whether a function or type is exported at its declaration (i.e., export type ...) instead of having to do it in two places: the declaration and the index.

For example, this PR is necessary because an exported type wasn't added to the index, and it was only noticed when a consumer of the AccountsController tried to use it. This means we have to update the index, release a new version of AccountsController, and update its dependents.

@ccharly
Copy link
Contributor Author

ccharly commented Jan 31, 2025

@mcmire

Can you explain what you mean by error-prone?

Yes that's exactly what you describe. "error-prone" was probably not the best term for this, sorry 🙈

I guess we should have been more rigorous when doing our PRs, that's true. 😅

IMHO (and I think that's really a personal opinion here), it seems like we are doing double the work by exporting "twice". I haven't seen any guideline regarding those exports here:

However, if we decide to have a unified pattern/convention for all controllers, we'll follow it, np!

For now, I'll go with this export * since that's what we do for some other controllers already.

@ccharly ccharly marked this pull request as ready for review January 31, 2025 09:54
@ccharly ccharly requested a review from a team as a code owner January 31, 2025 09:54
@ccharly ccharly merged commit 7598f7c into main Jan 31, 2025
124 checks passed
@ccharly ccharly deleted the fix/missing-accounts-controller-exports branch January 31, 2025 12:27
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.

3 participants