Incorporated in my React application is an object that I devised. Within this object, there is the following definition for Props:
type Props = { message: MessageTypes | MessageImgTypes; showTimeStamp: boolean; }
If we assume that MessageTypes consists of the structure shown:
interface MessageTypes { text: string; };
And MessageImgTypes has the following structure:
interface MessageImgTypes { text?: string; textImg : string; };
Upon attempting to access the textImg property of MessageImgTypes, an error arises indicating:
"Property 'textImg' does not exist on type 'MessageTypes | MessageImgTypes'." Despite being a union, the aforementioned property should indeed exist within the MessageImgType declaration. I contemplated using Narrowing to create two branches, but found that typeof and instanceof are incompatible with these interfaces.