Examples
class Base {
run() {
throw abstractMethod(this, Base, Base.prototype.run)
}
}
class Child extends Base {}
new Child().run() // throws: the method is not implementedFunction
abstractMethod<U extends ConstructorFn, T extends any>(item: T, baseConstructor: U, method: object): neverThrows a message explaining why an abstract method cannot be called for an item.
When item.constructor is exactly baseConstructor, the method is not
callable because the base class is abstract. For any other constructor, the
method is treated as unimplemented and should be overridden. The thrown
value is a formatted string, not an Error instance.
class Base {
run() {
throw abstractMethod(this, Base, Base.prototype.run)
}
}
class Child extends Base {}
new Child().run() // throws: the method is not implemented