Take into consideration the following scenario:
class Base{
}
class A extends Base{
}
class B {
}
Now, I am looking to encapsulate the implementation (type) of Base
within an object.
interface MyImpl{
name:string;
impl:any;
}
How can we specify the type for impl
instead of using any
, so that {name:"Aname", impl: A}
is considered valid while {name:"Bname",impl:B}
is considered invalid?