I'm using Typescript in my React Native app, and have different types/interfaces for various Android/iOS objects. For example, I have a receipt
object that is of type AndroidReceipt
on Android, and type iOSReceipt
on iOS. The way I'm doing this now is
let receipt: Platform.OS === 'android' ? AndroidReceipt : iOSReceipt
Is there a simpler way to do this, rather than having to put a ternary statement in every time I want to enforce typing?