DEV Community

Discussion on: CRA typescript is compiling slow

Collapse
 
3sanket3 profile image
Sanket Patel

Hey @cubiclebuddha , how to you manage the context to avoid circular dependencies.

For example:
The way we generally do, I have context declared and provided in app.tsx. The app.tsx have dependency of let say page-one.tsx and I want to consume the context in page-one.tsx. (obviously in such scenario passing the props itself enough but consider a deep hierarchy that needs context) Such scenarios will create circular dependency. Do you suggest declaring the context variable in altogether separate file?

Also, I want to test some good production application(not library) built using CRA typescript with mine. So that I can compare and better understand. Do you have any such opensource application in mind?

Thread Thread
 
cubiclebuddha profile image
Cubicle Buddha

If I have a circular dependency between a.ts and b.ts, I pull out the shared code into c.ts and use that in a and b. It shouldn’t matter if it’s function or a function component because it’s all just references.

And sadly, no I don’t know of a good example of a create React app in TypeScript. I’m only just beginning on React myself. Sadly I was stuck in Angular 1 for a long time. 🤮

Thread Thread
 
3sanket3 profile image
Sanket Patel

Haha Welcome buddy. And we are beginner with TypeScript in React.

I tried Madge and solved all circular dependencies but still there is no significant improvement with that. So not sure if there is something else to check or it's just the way it will be.

Thanks :)