I have a recurring problem that is caused by someone importing from a module that should only be used locally.
Imagine the following setup:
- src/app/index.js -> imports from src/lib/i18n/index.js
- src/lib/i18n/index.js -> imports from src/lib/i18n/text.js
- src/lib/i18n/text.js
In the above example src/app/index.js
is the main application entry point and src/lib/i18n/index.js
contains the api for the i18n. The file src/app/index.js
contains the public i18n API and itself imports from 'src/lib/i18n/text.js'.
I would now like to keep people from bypassing the actual i18n api defined in src/lib/i18n/index.js
by directly accessing 'src/lib/i18n/text.js'.
Is there a way to do this in TypeScript?