I have an array of objects like:
const menuItems = ref([
{
id: 'home',
name: 'Home',
routerPath: '/',
submenus: null
},
{
id: 'about',
name: 'About',
routerPath: '/about',
submenus: [
{
id: 'behfar-negin',
name: 'Behfar Negin',
routerPath: '/about/behfar-negin'
}
]
},
{
id: 'blog',
name: 'Blog',
routerPath: '/blog',
submenus: null
}
]);
And I have defined a function where I change the active menu based on the name it's given:
function setActiveMenu(name: string) {
let target = menuItems.value.find(item => item.name.toLowerCase() == name.toLowerCase());
if(target != undefined)
target.name = name;
}
However I get this on the != comparison:
Condition is always true since types '{name: UnwrapRef<string>, id: UnwrapRef<string>, routerPath: UnwrapRef<string>, submenus: UnwrapRef<null>} | {name: UnwrapRef<string>, id: UnwrapRef<string>, routerPath: UnwrapRef<string>, submenus: UnwrapRef<{name: string, id: string, routerPath: string}[]>} | {name: UnwrapRef<string>, id: UnwrapRef<string>, routerPath: UnwrapRef<string>, submenus: UnwrapRef<({name: string, id: string} | {name: string, id: string} | {name: string, id: string} | {name: string, id: string})[]>} | {name: UnwrapRef<string>, id: UnwrapRef<string>, routerPath: UnwrapRef<string>, submenus: UnwrapRef<null>}' and 'undefined' have no overlap
However I also see this in MDN.
Do I have to do something else?