Is it possible to get the parent class of a TypeScript class at runtime? I mean, for example, within a decorator:
export function CustomDecorator(data: any) {
return function (target: Function) {
var parentTarget = ?
}
}
My custom decorator is applied this way:
export class AbstractClass {
(...)
}
@CustomDecorator({
(...)
})
export class SubClass extends AbstractClass {
(...)
}
Within the decorator, I would like to have an instance to AbstractClass
.
Thanks very much for your help!
You can use the Object.getPrototypeOf function.
Something like:
Edit
After the code @DavidSherret added (in a comment), here's what you want (I think):
Or as @DavidSherret noted:
2nd Edit
Ok, so here's what I hope to be you goal: