Support static members

This commit is contained in:
proteriax 2021-07-22 10:14:10 -04:00
parent 563d5d9c34
commit 904229a885
3 changed files with 7 additions and 2 deletions

View File

@ -66,7 +66,9 @@ export default ({ types: t }: typeof babel): babel.PluginObj<State> => ({
modifiers.push(
t.callExpression(state.__decorate(), [
t.arrayExpression(child.decorators.map(d => d.expression)),
t.memberExpression(classID, t.identifier("prototype")),
child.static
? classID
: t.memberExpression(classID, t.identifier("prototype")),
t.isIdentifier(child.key) ? t.stringLiteral(child.key.name) : child.key,
t.unaryExpression("void", t.numericLiteral(0)),
])

View File

@ -1,4 +1,5 @@
class A {
@dec prop: string
@dec @dec2 prop2: string
@dec static staticProp: number
}

View File

@ -3,7 +3,9 @@ import { __decorate } from "tslib"
class A {
prop: string;
prop2: string;
static staticProp: number;
}
__decorate([dec], A.prototype, "prop", void 0);
__decorate([dec, dec2], A.prototype, "prop2", void 0);
__decorate([dec, dec2], A.prototype, "prop2", void 0);
__decorate([dec], A, "staticProp", void 0);