Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Create a ~/types directory to store shared types and move types out of ~/models into the new directory #1161

Closed
1 task
sarayourfriend opened this issue Mar 22, 2022 · 3 comments · Fixed by #1997
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed ⌨️ tech: typescript Requires familiarity with TypeScript

Comments

@sarayourfriend
Copy link
Contributor

sarayourfriend commented Mar 22, 2022

Problem

We've been putting most of the shared types for the app into the ~/stores/types.ts module. This module is getting long and complicated. It'd be nice to split it into smaller modules and place them in a top-level ~/types directory.

Description

Split ~/stores/types.ts into several smaller modules placed in a new ~/types directory. Additionally export types from an ~/types/index.ts so that it's easy to import types from a single import instead of having to reach for the specific module.

As @dhruvkb pointed out there is an already existing ~/models directory. The types from there should be moved into ~/types and merged with the other types.

Implementation

  • 🙋 I would be interested in implementing this feature.
@sarayourfriend sarayourfriend added 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users ⌨️ tech: typescript Requires familiarity with TypeScript labels Mar 22, 2022
@sarayourfriend sarayourfriend changed the title Create a ~/types directory to store shared types. Create a ~/types directory to store shared types Mar 22, 2022
@dhruvkb
Copy link
Member

dhruvkb commented Mar 22, 2022

@sarayourfriend some of my PRs have used the models/ directory to put shared interfaces (sorry if that's anti-conventional, I was coming at this from a Django-PoV). Should we update the issue to go ahead with models/ or move the existing code to types/?

@sarayourfriend
Copy link
Contributor Author

types matches the package.json key for a package's type root as well as the @types prefix for definitely typed packages. I think it matches TypeScript more. But open to whatever the team wants to do, if folks like models more.

To me models reads more like database models (like something we'd use to connect to an ORM specifically) not just types that don't have any runtime implications.

@dhruvkb
Copy link
Member

dhruvkb commented Mar 22, 2022

The main reasoning behind the models/ name was that it started out with the same classes that API has in its models, namely Media, Audio etc. But yeah, I agree that types/ makes more sense. So the scope of the issue should be expanded to rename the models/ directory to types/.

@sarayourfriend sarayourfriend changed the title Create a ~/types directory to store shared types Create a ~/types directory to store shared types and move types out of ~/models into the new directory Mar 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed ⌨️ tech: typescript Requires familiarity with TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants