@strapi/typescript-utils 5.31.0 → 5.31.2

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 node = toTypeLiteral(42);
171
+ const nodePositive = toTypeLiteral(42);
172
+ const nodeNegative = toTypeLiteral(-42);
172
173
 
173
- expect(node.kind).toBe(ts.SyntaxKind.FirstLiteralToken);
174
- expect(node.text).toBe('42');
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 factory.createNumericLiteral(data);
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/typescript-utils",
3
- "version": "5.31.0",
3
+ "version": "5.31.2",
4
4
  "description": "Typescript support for Strapi",
5
5
  "keywords": [
6
6
  "strapi",