I've recently delved into using typescript
. Currently, I'm faced with a scenario where I need to import available types
from backend endpoints. In one specific instance, an endpoint can support two types as parameters.
Example:
interface B extends A {
value?: string,
values?: string[]
}
Here, A
represents the type imported from the backend, and it may have either value: string
or values: string[]
.
Currently, I've made both properties optional in the interface B
, but I believe this is not the ideal solution. How can I structure interface B
so that it only contains either value
or values
?
Thank you.