mardi 18 juillet 2017

Can an overridden method be detected at runtime in TypeScript?

E.g. is it possible to do something like this?..

export default class SuperClass {
    public method(): void {
        /* noop */
    }
}

export default class SubClass extends SuperClass {
    public method(): void {
        /* useful work */
    }
}


export default class SmallerClass extends SuperClass {

}

let a = new SubClass();
let b = new SmallerClass();

/* Something like this?.. */
a.overrides("method") => true;
b.overrides("method") => false;





Aucun commentaire:

Enregistrer un commentaire