How can I assert that the profile is UserProfileForAdmin type only inside the isAdmin
JSX area to display the phone number only for the admins.
import { View, Text } from "react-native";interface Profile { name: string;}interface UserProfileForAdmin extends Profile { phone: string;}export interface HomeSingleProfileProps { profile: Profile | UserProfileForAdmin; isAdmin: boolean;}const SingleProfile = (props: HomeSingleProfileProps) => { return (<View><Text> {props.isAdmin ? (<> {props.profile.phone}</> ) : (<> {props.profile.name}</> )}</Text></View> );};export default SingleProfile;
Currently it gives the error
TS2339: Property 'phone' does not exist on type 'Profile | UserProfileForAdmin'. Property 'phone' does not exist on type 'Profile'.