I have a nestjs dto classes. Use it for response dto.
class A {
response: '1',
prop1: string
}
class B {
response: '2',
prop2: string
}
Everything works
function foo ():A|B {
const result:A|B = bar();
if (result.response === '1') {
// get result.prop1
}
}
Is it possible to union A and B classes in C? So we not need to union it in foo function.
Looked in https://docs.nestjs.com/openapi/mapped-types, but there is no union type.