I am trying to implement a method in a superclass that should be available for use, but not modified, in subclasses. Consider this:
export abstract class BaseClass { universalBehavior(): void { doStuff(); // Do some universal stuff the same way in all sub classes specializedBehavior(); // Delegate specialized stuff to sub classes } protected abstract specializedBehavior(): void; }
My intention was that any subclass of BaseClass could not only omit the implementation of universalBehavior() , but not even be able to provide an implementation. Isn't that still possible in TypeScript? Intellisense complains when I omit the implementation in my subclasses. The best I can do is the following:
export class SubClass extends BaseClass { universalBehavior(): void { super.universalBehavior(); } specializedBehavior(): void {
Obviously, this is problematic because I have to ensure that no subclass ever implements universalBehavior() with anything other than calling super.universalBehavior() .
source share