Is there any way to define getInterface
in this context so that res has the type number
?
To clarify: I am not trying to write these methods, I have an enviroment where a method exists which returns different objects depending on parameters.type, and I'm trying to find a way to type them
interface A {
tag: 'a'
do_one: () => number;
}
interface B {
tag: 'b'
do_one: () => string;
}
type Interface = A | B
let one = getInterface({ type: 'a' })
let res = one.do_one()