json-as 0.5.12 → 0.5.13
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/package.json +1 -1
- package/transform/lib/index.js +11 -4
- package/transform/package.json +1 -1
package/package.json
CHANGED
package/transform/lib/index.js
CHANGED
|
@@ -20,6 +20,8 @@ class AsJSONTransform extends ClassDecorator {
|
|
|
20
20
|
}
|
|
21
21
|
visitMethodDeclaration() { }
|
|
22
22
|
visitFieldDeclaration(node) {
|
|
23
|
+
if (toString(node).startsWith("static"))
|
|
24
|
+
return;
|
|
23
25
|
const lineText = toString(node);
|
|
24
26
|
if (lineText.startsWith("private"))
|
|
25
27
|
return;
|
|
@@ -46,10 +48,15 @@ class AsJSONTransform extends ClassDecorator {
|
|
|
46
48
|
//);
|
|
47
49
|
}
|
|
48
50
|
visitClassDeclaration(node) {
|
|
49
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d;
|
|
50
52
|
if (!node.members) {
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
55
|
+
// Prevent from being triggered twice
|
|
56
|
+
for (const member of node.members) {
|
|
57
|
+
if (member.name.text == "__JSON_Serialize")
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
53
60
|
this.currentClass = {
|
|
54
61
|
name: toString(node.name),
|
|
55
62
|
keys: [],
|
|
@@ -66,9 +73,9 @@ class AsJSONTransform extends ClassDecorator {
|
|
|
66
73
|
return v;
|
|
67
74
|
}
|
|
68
75
|
});
|
|
69
|
-
if (parentSchema.length > 0) {
|
|
70
|
-
(
|
|
71
|
-
this.currentClass.encodeStmts.push(...(
|
|
76
|
+
if (parentSchema.length > 0 && ((_a = parentSchema[0]) === null || _a === void 0 ? void 0 : _a.encodeStmts)) {
|
|
77
|
+
(_b = parentSchema[0]) === null || _b === void 0 ? void 0 : _b.encodeStmts.push(((_c = parentSchema[0]) === null || _c === void 0 ? void 0 : _c.encodeStmts.pop()) + ",");
|
|
78
|
+
this.currentClass.encodeStmts.push(...(_d = parentSchema[0]) === null || _d === void 0 ? void 0 : _d.encodeStmts);
|
|
72
79
|
}
|
|
73
80
|
else {
|
|
74
81
|
//console.log("Class extends " + this.currentClass.parent + ", but parent class not found. Maybe add the @json decorator over parent class?")
|