(name: string) => void
b: (value: number) => void
}
Is there a way to get an intersection of the values? E.g.
(name: string) => void | (value: number) => void
I have tried using Item[keyof Item]. But this method is returning me Union type
why not defining them separately? like type typeA = (name: string) => void type typeB = (value: number) => void interface Item { a: typeA; b: typeB; } and then using typeA | typeB? also you can use Enums, doesn't help much with code complication, but still...
Because I will be getting the "Item" from a library. There are ~48 methods in this Item. So I'm seeking for a programmatic way
so the interface you showed is an example of what libray provides, you need to get the type of Item.a and Item.b to use them with a union, right?
For intersection you want &
What you are describing is also the union type
Обсуждают сегодня