@travetto/transformer 5.0.0-rc.2 → 5.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -7
- package/package.json +1 -1
- package/src/util/decorator.ts +20 -9
package/README.md
CHANGED
|
@@ -104,20 +104,16 @@ export class Test {
|
|
|
104
104
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105
105
|
exports.TEST = void 0;
|
|
106
106
|
const tslib_1 = require("tslib");
|
|
107
|
-
const Ⲑ_decorator_1 = tslib_1.__importStar(require("@travetto/registry/src/decorator.js"));
|
|
108
107
|
const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js"));
|
|
109
108
|
var ᚕm = ["@travetto/transformer", "doc/upper"];
|
|
110
|
-
|
|
111
|
-
static Ⲑinit = Ⲑ_function_1.
|
|
109
|
+
class TEST {
|
|
110
|
+
static Ⲑinit = Ⲑ_function_1.registerFunction(TEST, ᚕm, { hash: 649563175, lines: [1, 9] }, { COMPUTEAGE: { hash: 1286718349, lines: [6, 8, 7] } }, false, false);
|
|
112
111
|
NAME;
|
|
113
112
|
AGE;
|
|
114
113
|
DOB;
|
|
115
114
|
COMPUTEAGE() {
|
|
116
115
|
this['AGE'] = (Date.now() - this.DOB.getTime());
|
|
117
116
|
}
|
|
118
|
-
}
|
|
117
|
+
}
|
|
119
118
|
exports.TEST = TEST;
|
|
120
|
-
exports.TEST = TEST = tslib_1.__decorate([
|
|
121
|
-
Ⲑ_decorator_1.Register()
|
|
122
|
-
], TEST);
|
|
123
119
|
```
|
package/package.json
CHANGED
package/src/util/decorator.ts
CHANGED
|
@@ -6,20 +6,31 @@ import { CoreUtil } from './core';
|
|
|
6
6
|
*/
|
|
7
7
|
export class DecoratorUtil {
|
|
8
8
|
|
|
9
|
+
static #getIdentFromExpression(e: ts.Expression): ts.Identifier {
|
|
10
|
+
if (ts.isCallExpression(e) && ts.isIdentifier(e.expression)) {
|
|
11
|
+
return e.expression;
|
|
12
|
+
} else if (ts.isIdentifier(e)) {
|
|
13
|
+
return e;
|
|
14
|
+
} else if (ts.isCallExpression(e) && ts.isPropertyAccessExpression(e.expression) && ts.isIdentifier(e.expression.expression)) {
|
|
15
|
+
return e.expression.expression;
|
|
16
|
+
} else if (ts.isPropertyAccessExpression(e) && ts.isCallExpression(e.expression) && ts.isIdentifier(e.expression.expression)) {
|
|
17
|
+
return e.expression.expression;
|
|
18
|
+
} else if (ts.isParenthesizedExpression(e)) {
|
|
19
|
+
return this.#getIdentFromExpression(e.expression);
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error('No Identifier');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
/**
|
|
10
26
|
* Get identifier for a decorator
|
|
11
27
|
*/
|
|
12
28
|
static getDecoratorIdent(d: ts.Decorator): ts.Identifier {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} else if (ts.isIdentifier(d.expression)) {
|
|
16
|
-
return d.expression;
|
|
17
|
-
} else if (ts.isCallExpression(d.expression) && ts.isPropertyAccessExpression(d.expression.expression) && ts.isIdentifier(d.expression.expression.expression)) {
|
|
18
|
-
return d.expression.expression.expression;
|
|
19
|
-
} else if (ts.isPropertyAccessExpression(d.expression) && ts.isCallExpression(d.expression.expression) && ts.isIdentifier(d.expression.expression.expression)) {
|
|
20
|
-
return d.expression.expression.expression;
|
|
21
|
-
} else {
|
|
29
|
+
const ident = this.#getIdentFromExpression(d.expression);
|
|
30
|
+
if (!ident) {
|
|
22
31
|
throw new Error('No Identifier');
|
|
32
|
+
} else {
|
|
33
|
+
return ident;
|
|
23
34
|
}
|
|
24
35
|
}
|
|
25
36
|
|