Consider the scenario where a variable may hold either a string or an object with properties like this:
value?: string | { name: string, type: string }
Attempting to work with it below leads to a compile error:
console.log(value?.name || value)
console.log(value?.type)
Any suggestions on how to properly handle such a variable that can have different types?