I have the following code in typescript
Array.map((r: number | PointOptionsObject | [string, number | null] | null ) => {
if (r) {
;`
${r.phrase}:
<span> hello </span>
`
}
})
I am getting an error in typescript, property phrase doesn't exist on type number essentially the only data that I am using is of type PointOptionsObject which has the phrase property.. But I am forced to use this long declaration for each of the data items in the array's type because it is the type of the built in library. If I change my code to have
if(typeof r !== "number")
Then I get a new error Property 'phrase' does not exist on type '[string, number | null]'
And here is where I am stuck, I am not sure how to check the type of this and we cant using the built in typeof operator. How can I check that the value of r is only the PointOptionsObject?