I have 2 interfaces and AllTypes
type:
interface A {
// ...
}
interface B {
// ...
}
type AllTypes = A | B;
How can I use a generic to make sure an argument to a function is object with interface A
or B
?
// pseudocode
function test<T oneof AllTypes>(argument: T): void {
// ...
}
CodePudding user response:
Try this:
<T extends AllTypes>