I've searched trough the stackoverflow questions but didn't find the needed answer in my case.
I have
interface FruitBox {
name: string
desc: {
'orange': number;
'banana': number;
}
}
interface IceBox {
name: string
}
interface Vegabox {
name: string
desc: {
'tomato': number;
'potato': number;
}
}
type UnionBox = FruitBox | Vegabox | IceBox;
What I'm trying to implement
type Ship = Record<string, (description: UnionBox['desc'] | UnionBox['name']) => void>;
I'm trying to assign a description property to a type of UnionBox['desc'] and if desc parameter doesn't exist, then assign it to the UnionBox['name']
Receiving next error:
Property 'desc' does not exist on type 'UnionBox'
Would be glad for any help or hint
ps. I understand that there must be some weird algorithm, Just not sure in which way to look