Closed
Description
We are using TypeScript to write our React Native application and encountered an issue with platform specific extensions provided by RN.
React Native will detect when a file has a .ios. or .android. extension and load the right file for each platform when requiring them from other components.
For example, you can have these files in your project:
BigButton.ios.js
BigButton.android.js
With this setup, you can just require the files from a different component without paying attention to the platform in which the app will run.
import BigButton from './components/BigButton';
When we use tsc to compile our code, it won't recognize the android or ios platform extension. What about have a customPlatform
option that's similar to allowJs
that auto prepend the platform name to supportedTypeScriptExtensions
?
function getSupportedExtensions(options) {
if (options && options.customPlatform) {
return ts.supportedTypeScriptExtensions.concat(ts.supportedTypeScriptExtensions.map((ext) => `.${options.customPlatform}${ext}`))
}
return options && options.allowJs ? allSupportedExtensions : ts.supportedTypeScriptExtensions;
}