If we have a base Parent
class with child classes ChildA
and ChildB
abstract class Parent {
abstract foo()
}
class ChildA extends Parent {
foo() { }
bar() { }
}
class ChildB extends Parent {
foo() { }
baz() { }
}
The challenge is to create a function that can specify a parameter as any class (the actual class, not an instance) that follows the type structure of Parent
, but is not specifically the class Parent
itself
fn(Parent) // Should fail, this is the superclass instead of subclass
fn(new ChildA()) // should fail, this is an instance rather than the class itself
fn(new ChildB()) // should fail, this is an instance rather than the class itself
fn(ChildA) // Should succeed
fn(ChildB) // Should succeed