@travetto/transformer 5.0.10 → 5.0.11
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/LICENSE +1 -1
- package/package.json +4 -4
- package/src/importer.ts +2 -2
- package/src/util/literal.ts +9 -1
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/transformer",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.11",
|
|
4
4
|
"description": "Functionality for AST transformations, with transformer registration, and general utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"directory": "module/transformer"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/manifest": "^5.0.
|
|
28
|
-
"tslib": "^2.8.
|
|
29
|
-
"typescript": "^5.
|
|
27
|
+
"@travetto/manifest": "^5.0.10",
|
|
28
|
+
"tslib": "^2.8.1",
|
|
29
|
+
"typescript": "^5.7.2"
|
|
30
30
|
},
|
|
31
31
|
"travetto": {
|
|
32
32
|
"displayName": "Transformation",
|
package/src/importer.ts
CHANGED
|
@@ -126,8 +126,8 @@ export class ImportManager {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// Allow for node classes to be imported directly
|
|
129
|
-
if (/@types\/node
|
|
130
|
-
file = PackageUtil.resolveImport(file.
|
|
129
|
+
if (/@types\/node\//.test(file)) {
|
|
130
|
+
file = PackageUtil.resolveImport(file.split('@types/node/')[1].replace(D_OR_D_TS_EXT_RE, ''));
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
if (!D_OR_D_TS_EXT_RE.test(file) && !this.#newImports.has(file)) {
|
package/src/util/literal.ts
CHANGED
|
@@ -52,7 +52,8 @@ export class LiteralUtil {
|
|
|
52
52
|
} else if (typeof val === 'string') {
|
|
53
53
|
val = factory.createStringLiteral(val);
|
|
54
54
|
} else if (typeof val === 'number') {
|
|
55
|
-
|
|
55
|
+
const res = factory.createNumericLiteral(Math.abs(val));
|
|
56
|
+
val = val < 0 ? factory.createPrefixMinus(res) : res;
|
|
56
57
|
} else if (typeof val === 'boolean') {
|
|
57
58
|
val = val ? factory.createTrue() : factory.createFalse();
|
|
58
59
|
} else if (val instanceof RegExp) {
|
|
@@ -107,6 +108,13 @@ export class LiteralUtil {
|
|
|
107
108
|
} else {
|
|
108
109
|
return parseInt(txt, 10);
|
|
109
110
|
}
|
|
111
|
+
} else if (ts.isPrefixUnaryExpression(val) && val.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(val.operand)) {
|
|
112
|
+
const txt = val.operand.text;
|
|
113
|
+
if (txt.includes('.')) {
|
|
114
|
+
return -parseFloat(txt);
|
|
115
|
+
} else {
|
|
116
|
+
return -parseInt(txt, 10);
|
|
117
|
+
}
|
|
110
118
|
} else if (val.kind === ts.SyntaxKind.FalseKeyword) {
|
|
111
119
|
return false;
|
|
112
120
|
} else if (val.kind === ts.SyntaxKind.TrueKeyword) {
|