DEV Community

Cover image for How to Detect and Fix Circular Dependencies in Typescript

How to Detect and Fix Circular Dependencies in Typescript

Dany Paredes on March 15, 2024

When coding in TypeScript or Angular and embracing types, sometimes we don't pay attention to "Circular dependencies". We create types and try to u...
Collapse
 
brense profile image
Rense Bakker

What's the problem though? Because tsc didn't report an error and the app is working as expected you said? This shouldn't be an issue because modules are only imported once and imported modules are available in the global scope, so their import order doesn't matter. Unless both modules need to initialize something that requires a variable from the other module that's only set after initialization. In that case you will get a runtime error.

Collapse
 
bugzpodder profile image
bugzpodder

next js fast refresh might break due to circular references