Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ReactJs Typescript file structure

I have an ReactJs project and I am organizing my files. Is it best to create a folder for interfaces and a different folder for types or should we keep the interfaces and types together

example

MyProject
 -src
  -components
  -interfaces
    -editorInterface
  -type
    -editorTypes

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I use the below structure

src/
└── ts
    ├── enums
    │   ├── app_enums.ts
    │   └── db_enums.ts
    ├── interfaces
    │   ├── app_interfaces.ts
    │   ├── db_interfaces.ts
    │   └── global_interfaces.ts
    └── types
        └── app_types.ts

Directories names express their purpose well. interfaces directory includes all interfaces and types directory includes all type aliases you use in your project.You can merge these directories if you wish but I found splitting types semantically and structurally is really helpful when managing large code bases. Try to figure out what works best for you. There is no golden rule when it comes to project directory structure

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading