When decorating a class with export statement, decorator applied to the local class, but the exported one won't be decorated.
source:
class cA {
foo() {
console.log("?")
}
}
function decoA(target: {new(): cA}) {
return class extends target {
bar() {
console.log("!")
}
}
}
@decoA
export class cB extends cA {}
tstl:
local ____exports = {}
local cA = __TS__Class()
cA.name = "cA"
function cA.prototype.____constructor(self)
end
function cA.prototype.foo(self)
print("?")
end
local function decoA(self, target)
return (function()
local ____ = __TS__Class()
____.name = ____.name
__TS__ClassExtends(____, target)
function ____.prototype.bar(self)
print("!")
end
return ____
end)()
end
____exports.cB = __TS__Class()
local cB = ____exports.cB
cB.name = "cB"
__TS__ClassExtends(cB, cA)
cB = __TS__Decorate({decoA}, cB)
return ____exports
And tsc compilation:
tsc
class cA {
foo() {
console.log("?");
}
}
function decoA(target) {
return class extends target {
bar() {
console.log("!");
}
};
}
let cB = class cB extends cA {
};
cB = __decorate([
decoA
], cB);
export { cB };
When decorating a class with
exportstatement, decorator applied to the local class, but the exported one won't be decorated.source:
tstl:
And tsc compilation:
tsc