As I wrote in the comment, interfaces are not part of the compiled js, they are just used by the compiler who then emits them from the output.
As decorators are being executed at runtime then there's no information about the interface which you are decorating.
In the last example in the Decorators docs (Metadata section) they show that doing this:
class MyClass {
@MyDeco
myMember: MyType;
}
Is equivalent of doing:
class MyClass {
@MyDeco
@Reflect.metadata("design:type", MyType)
myMember: MyType;
}
Which is because if you don't include the @Reflect.metadata
part yourself then the compiler will add that for you.
But when MyType
is an interface then the compiler will substitute it with Object
, so this:
interface MyInterfaceType {}
class MyClassType {}
class MyClass {
@MyDeco
member1: MyClassType;
@MyDeco
member2: MyInterfaceType;
}
Is compiled to:
var MyClass = (function () {
function MyClass() {
}
__decorate([
MyDeco,
__metadata('design:type', MyClassType)
], MyClass.prototype, "member1", void 0);
__decorate([
MyDeco,
__metadata('design:type', Object)
], MyClass.prototype, "member2", void 0);
return MyClass;
}());
If you want to keep using interfaces and have their name, then I suggest that you'll have an optional parameter to your decorator which will receive the name, then when using this decorator on interfaces just place the name there.
I know that it kinda misses the point, but you don't really have more options (as I see it).