I am using a variable which has 2 types either string or Map. I want to check whether the variable is in type of string or Map. For that I have used the following code.
// description is like this description: string | Map<string, string>
if (description instanceof String) {
return description;
}else {
return description?.get('test');
}
But it gives me the following error.
Property 'get' does not exist on type 'string | Map'. Property 'get' does not exist on type 'string'
Please help me to solve the problem. Thanks.