I have a large project with many files and I believe using an import object would be beneficial. For instance, consider having menu.ts
at the top level that every program will refer to:
import router from "./router/index";
import controllers from "./controllers/index";
import config from "./config";
export default {
router: router,
controllers: controllers,
config: config
}
Here is an example of controllers/index.ts
:
import database from "./database";
import accounts from "./accounts";
import a_controller from "./a_controller";
export default {
database: database,
accounts: accounts,
a_controller: a_controller
}
However, this setup could lead to circular dependency issues with controllers referencing the menu. This can result in a
TypeError: cannot read property controllers of undefined
error message. Is there a solution to this problem?
Thank you for your assistance.