Setup
Webpack has a mainFiles module resolution which allows you to resolve some files depending on environment, like:
| Button| | - index.ts| | - index.performer.ts| | - index.customer.ts// Page.tsimport Button from './Button';
Similar works in react-native's platform-specific module resolution.
You can import button depending on a platform (environment, in other words)
| Button| | - index.ts| | - index.android.ts| | - index.ios.ts// App.tsimport Button from './Button';
Question:
How to tell typescript to resolve those import, and select correct file depending on environment?
The behavior is that webpack/metro will selects index.android.ts, but typescript think that we imported index.ts.
Thats the problem.