Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6212

webpack/metro mainFiles module resolution with typescript

$
0
0

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.


Viewing all articles
Browse latest Browse all 6212

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>