@strapi/typescript-utils 5.31.0 → 5.31.1
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.
|
@@ -168,10 +168,16 @@ describe('Utils', () => {
|
|
|
168
168
|
});
|
|
169
169
|
|
|
170
170
|
test('Number', () => {
|
|
171
|
-
const
|
|
171
|
+
const nodePositive = toTypeLiteral(42);
|
|
172
|
+
const nodeNegative = toTypeLiteral(-42);
|
|
172
173
|
|
|
173
|
-
expect(
|
|
174
|
-
expect(
|
|
174
|
+
expect(nodePositive.kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
175
|
+
expect(nodePositive.text).toBe('42');
|
|
176
|
+
|
|
177
|
+
expect(nodeNegative.kind).toBe(ts.SyntaxKind.PrefixUnaryExpression);
|
|
178
|
+
expect(nodeNegative.operator).toBe(ts.SyntaxKind.MinusToken);
|
|
179
|
+
expect(nodeNegative.operand.kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
180
|
+
expect(nodeNegative.operand.text).toBe('42');
|
|
175
181
|
});
|
|
176
182
|
|
|
177
183
|
test('Boolean', () => {
|
|
@@ -92,7 +92,12 @@ const toTypeLiteral = (data) => {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (isNumber(data)) {
|
|
95
|
-
return
|
|
95
|
+
return data < 0
|
|
96
|
+
? factory.createPrefixUnaryExpression(
|
|
97
|
+
ts.SyntaxKind.MinusToken,
|
|
98
|
+
factory.createNumericLiteral(-data)
|
|
99
|
+
)
|
|
100
|
+
: factory.createNumericLiteral(data);
|
|
96
101
|
}
|
|
97
102
|
|
|
98
103
|
if (isBoolean(data)) {
|