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

Clean up module imports across repo #437

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

Conversation

echang594
Copy link
Contributor

Info

Closes #192.

Description

What changes did you make? List all distinct problems that this PR addresses. Explain any relevant
motivation or context.

  1. Add barrel files
  2. Change relative imports to absolute imports using module-alias

Changes

  • Barrel index.ts files on all folders that are imported
  • Barrel files themselves use regular relative imports including file name
  • All other imports use aliased barrel files (starting with @) even within the folder itself
  • New root level aliases.ts file programmatically adds aliases, this file is imported relatively
  • Also added to tsconfig.json to fix type hinting and jest.config.json because it uses its own aliases

Notes

  • Feedback and Event Validators have conflicting exports so they are currently unchanged
  • Because TypeScript already uses @types for special purposes, the alias for it is @customtypes
  • Tests folder has one alias with subfolders instead of having aliases for each subfolder for better organization and because some names collide
  • Similar thing with types folder for organization
  • The api/ subfolders each have their own alias due to their heavy usage
  • There are 3 points of entry: index.ts, ormconfig.ts, and Seeds.ts which each need to import the aliases because they are ran separately on different commands
  • Aliases are created programmatically rather than in package.json because build paths differ once it is compiled (untested)

Type of Change

  • Patch (non-breaking change/bugfix)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to not work as
    expected)
  • Documentation (A change to a README/description)
  • Continuous Integration/DevOps Change (Related to deployment steps, continuous integration
    workflows, linting, etc.)
  • Other: Style change

If you've selected Patch, Minor, or Major as your change type, make sure to bump the version before merging in package.json!

Testing

I have tested that my changes fully resolve the linked issue ...

  • locally.
  • on the testing API/testing database.
  • with appropriate Postman routes. Screenshots are included below.

Checklist

  • I have performed a self-review of my own code.
  • I have followed the style guidelines of this project.
  • I have appropriately edited the API version in the package.json file.
  • My changes produce no new warnings.

Screenshots

Please include a screenshot of your Postman testing passing successfully.

Not sure if its necessary for this kind of change.

Copy link

Thanks for contributing!
If you've made changes to the API's functionality, please make sure to bump the package
version—see this guide to semantic versioning for details—and
document those changes as appropriate.

aliases.ts Show resolved Hide resolved
@echang594 echang594 requested a review from dowhep April 25, 2024 00:20
@echang594 echang594 linked an issue May 11, 2024 that may be closed by this pull request
@sumeet-bansal sumeet-bansal removed their request for review September 13, 2024 01:13
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.

Clean up module imports across repo
2 participants