From 904229a8853b7cb950a8a1856df5dc0be9a9d023 Mon Sep 17 00:00:00 2001 From: proteriax <8125011+proteriax@users.noreply.github.com> Date: Thu, 22 Jul 2021 10:14:10 -0400 Subject: [PATCH] Support static members --- src/index.ts | 4 +++- test/snapshots/properties/input.txt | 1 + test/snapshots/properties/output.txt | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index fc89d9c..6c29a8d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,9 @@ export default ({ types: t }: typeof babel): babel.PluginObj => ({ 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)), ]) diff --git a/test/snapshots/properties/input.txt b/test/snapshots/properties/input.txt index 4a62286..0bfec8e 100644 --- a/test/snapshots/properties/input.txt +++ b/test/snapshots/properties/input.txt @@ -1,4 +1,5 @@ class A { @dec prop: string @dec @dec2 prop2: string + @dec static staticProp: number } diff --git a/test/snapshots/properties/output.txt b/test/snapshots/properties/output.txt index 6a8edc3..635fa00 100644 --- a/test/snapshots/properties/output.txt +++ b/test/snapshots/properties/output.txt @@ -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); \ No newline at end of file +__decorate([dec, dec2], A.prototype, "prop2", void 0); +__decorate([dec], A, "staticProp", void 0); \ No newline at end of file