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

React Native: platform specific import

$
0
0

Got this weird situation. Building for react native and using a native package from Intercom. Importing it works fine when android or ios. But for the web (or node jest) it throws an error.So have to do some face-pattern "hacking" like this

utilities/Intercom/index.ios.ts

export { default } from '@intercom/intercom-react-native'

utilities/Tntercom/index.web.ts

export default function Intercom() {}
// @ts-ignoreimport Intercom from '~/utilities/Intercom'

Not only does TS complain, but I also loses all types 😭

Is there any other way to do platform specific import and keep the native types?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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