I am new to typescript
I have an interface ABC in which I want either propA or propB to be there. it also have other properties
interface ABC {
propA: string
propB: string
propC: string
propD?: string
}
How can I do that?
I did this based on this answer https://stackoverflow.com/a/40510700/10433835
interface ABC {
propC: string
propD?: string
}
interface A extends ABC {
propA: string
}
interface B extends ABC {
propB: string
}
export type final = A | B
but then when I do something like this
function somethingCalled (a:A) {
}
const b:final = req.body
somethingCalled(b)
it throws following error Argument of type 'final' is not assignable to parameter of type 'interface A'.