Class ImplementableAbstract

Abstract class serving as a base for interface-like pure abstract classes that work with the "instanceof"-operator.

Usage:

  • Create a pure abstract class that extends Implementable that will serve as your interface. Specify the required attributes and methods within it as abstract.
  • Use your abstract class via the implements keyword exactly how you would use a regular interface.
  • Decorate the class that implements your abstract class using the static YOUR_ABSTRACT_CLASS.register method.
  • Now you can use the instanceof-operator with your abstract class.

Example:

import ƒ = FudgeCore;

abstract class MyInterface extends ƒ.Implementable {
public abstract myAttribute: string;
public abstract myMethod(): void;
}

@MyInterface.register
class MyClass implements MyInterface {
public myAttribute: string;
public myMethod(): void {}
}

let myInstance: MyInterface = new MyClass();
console.log(myInstance instanceof MyInterface); // true
console.log(MyClass.prototype instanceof MyInterface); // true

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • Type Parameters

    Parameters

    • this: T
    • _class: (new (...args) => InstanceType<T>)
        • new (...args): InstanceType<T>
        • Parameters

          • Rest ...args: any[]

          Returns InstanceType<T>

    • _context: ClassDecoratorContext<(new (...args) => any)>

    Returns void