Circular dependency when importing types from other features #39
SevenOutman
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's a common scenario when we import type definitions from other features, especially definitions for resources (fetched from APIs). If we expose everything from only the
index.ts
to other features, it's easy to encounter circular dependency.For example, if I'm writing a components in
teams
feature where typeUser
fromusers
feature is used:That will cause components from
users
to also be loaded because I re-exported them fromusers/index.ts
.Meanwhile I have a component in
users
feature that imports typeTeam
fromteams
feature:Now my
teams/components/MyComponent.ts
andusers/component/MyComponent.ts
forms a circular dependency.My solution is to import types from other features directly from their
./types.ts
, which means that./index.ts
is not reguarded as the only port of a feature.Same problem exists with importing APIs from other features. Any idea?
Beta Was this translation helpful? Give feedback.
All reactions