@strapi/typescript-utils 5.4.1 → 5.5.0
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.
|
@@ -680,18 +680,18 @@ describe('Attributes', () => {
|
|
|
680
680
|
expect(definition.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
681
681
|
expect(definition.members).toHaveLength(2);
|
|
682
682
|
|
|
683
|
-
const [
|
|
684
|
-
|
|
685
|
-
expect(min.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
686
|
-
expect(min.name.escapedText).toBe('min');
|
|
687
|
-
expect(min.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
688
|
-
expect(min.type.text).toBe('4');
|
|
683
|
+
const [max, min] = definition.members;
|
|
689
684
|
|
|
690
685
|
expect(max.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
691
686
|
expect(max.name.escapedText).toBe('max');
|
|
692
687
|
expect(max.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
693
688
|
expect(max.type.text).toBe('12');
|
|
694
689
|
|
|
690
|
+
expect(min.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
691
|
+
expect(min.name.escapedText).toBe('min');
|
|
692
|
+
expect(min.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
693
|
+
expect(min.type.text).toBe('4');
|
|
694
|
+
|
|
695
695
|
// Check for number keyword on the second typeArgument
|
|
696
696
|
expect(typeofMinMax.kind).toBe(ts.SyntaxKind.NumberKeyword);
|
|
697
697
|
});
|
|
@@ -830,24 +830,19 @@ describe('Attributes', () => {
|
|
|
830
830
|
expect(modifiers[0].typeArguments[0].kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
831
831
|
expect(modifiers[0].typeArguments[0].members).toHaveLength(2);
|
|
832
832
|
|
|
833
|
-
|
|
834
|
-
expect(modifiers[0].typeArguments[0].members[0].kind).toBe(
|
|
835
|
-
ts.SyntaxKind.PropertyDeclaration
|
|
836
|
-
);
|
|
837
|
-
expect(modifiers[0].typeArguments[0].members[0].name.escapedText).toBe('minLength');
|
|
838
|
-
expect(modifiers[0].typeArguments[0].members[0].type.kind).toBe(
|
|
839
|
-
ts.SyntaxKind.NumericLiteral
|
|
840
|
-
);
|
|
841
|
-
expect(modifiers[0].typeArguments[0].members[0].type.text).toBe('4');
|
|
833
|
+
const [maxLength, minLength] = modifiers[0].typeArguments[0].members;
|
|
842
834
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
);
|
|
846
|
-
expect(
|
|
847
|
-
expect(
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
expect(
|
|
835
|
+
// Max
|
|
836
|
+
expect(maxLength.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
837
|
+
expect(maxLength.name.escapedText).toBe('maxLength');
|
|
838
|
+
expect(maxLength.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
839
|
+
expect(maxLength.type.text).toBe('12');
|
|
840
|
+
|
|
841
|
+
// Min
|
|
842
|
+
expect(minLength.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
843
|
+
expect(minLength.name.escapedText).toBe('minLength');
|
|
844
|
+
expect(minLength.type.kind).toBe(ts.SyntaxKind.NumericLiteral);
|
|
845
|
+
expect(minLength.type.text).toBe('4');
|
|
851
846
|
});
|
|
852
847
|
});
|
|
853
848
|
|
|
@@ -247,13 +247,13 @@ describe('Utils', () => {
|
|
|
247
247
|
expect(objectNode.members).toHaveLength(2);
|
|
248
248
|
|
|
249
249
|
expect(objectNode.members[0].kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
250
|
-
expect(objectNode.members[0].name.escapedText).toBe('
|
|
251
|
-
expect(objectNode.members[0].type.kind).toBe(ts.SyntaxKind.
|
|
252
|
-
expect(objectNode.members[0].type.text).toBe('bar');
|
|
250
|
+
expect(objectNode.members[0].name.escapedText).toBe('bar');
|
|
251
|
+
expect(objectNode.members[0].type.kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
253
252
|
|
|
254
253
|
expect(objectNode.members[1].kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
255
|
-
expect(objectNode.members[1].name.escapedText).toBe('
|
|
256
|
-
expect(objectNode.members[1].type.kind).toBe(ts.SyntaxKind.
|
|
254
|
+
expect(objectNode.members[1].name.escapedText).toBe('foo');
|
|
255
|
+
expect(objectNode.members[1].type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
256
|
+
expect(objectNode.members[1].type.text).toBe('bar');
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
test('Object', () => {
|
|
@@ -262,20 +262,20 @@ describe('Utils', () => {
|
|
|
262
262
|
expect(node.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
263
263
|
expect(node.members).toHaveLength(2);
|
|
264
264
|
|
|
265
|
-
const [
|
|
265
|
+
const [barMember, fooMember] = node.members;
|
|
266
266
|
|
|
267
|
-
expect(
|
|
268
|
-
expect(
|
|
269
|
-
expect(
|
|
270
|
-
expect(
|
|
271
|
-
expect(firstMember.type.elements[0].kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
272
|
-
expect(firstMember.type.elements[1].kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
273
|
-
expect(firstMember.type.elements[2].kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
267
|
+
expect(barMember.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
268
|
+
expect(barMember.name.escapedText).toBe('bar');
|
|
269
|
+
expect(barMember.type.kind).toBe(ts.SyntaxKind.LiteralType);
|
|
270
|
+
expect(barMember.type.literal).toBe(ts.SyntaxKind.NullKeyword);
|
|
274
271
|
|
|
275
|
-
expect(
|
|
276
|
-
expect(
|
|
277
|
-
expect(
|
|
278
|
-
expect(
|
|
272
|
+
expect(fooMember.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
273
|
+
expect(fooMember.name.escapedText).toBe('foo');
|
|
274
|
+
expect(fooMember.type.kind).toBe(ts.SyntaxKind.TupleType);
|
|
275
|
+
expect(fooMember.type.elements).toHaveLength(3);
|
|
276
|
+
expect(fooMember.type.elements[0].kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
277
|
+
expect(fooMember.type.elements[1].kind).toBe(ts.SyntaxKind.TrueKeyword);
|
|
278
|
+
expect(fooMember.type.elements[2].kind).toBe(ts.SyntaxKind.FirstLiteralToken);
|
|
279
279
|
});
|
|
280
280
|
|
|
281
281
|
test('Object with complex keys', () => {
|
|
@@ -284,19 +284,19 @@ describe('Utils', () => {
|
|
|
284
284
|
expect(node.kind).toBe(ts.SyntaxKind.TypeLiteral);
|
|
285
285
|
expect(node.members).toHaveLength(2);
|
|
286
286
|
|
|
287
|
-
const [
|
|
287
|
+
const [fooBar, fooDashBar] = node.members;
|
|
288
288
|
|
|
289
|
-
expect(
|
|
290
|
-
expect(
|
|
291
|
-
expect(
|
|
292
|
-
expect(
|
|
293
|
-
expect(
|
|
289
|
+
expect(fooBar.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
290
|
+
expect(fooBar.name.kind).toBe(ts.SyntaxKind.Identifier);
|
|
291
|
+
expect(fooBar.name.escapedText).toBe('foo');
|
|
292
|
+
expect(fooBar.type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
293
|
+
expect(fooBar.type.text).toBe('bar');
|
|
294
294
|
|
|
295
|
-
expect(
|
|
296
|
-
expect(
|
|
297
|
-
expect(
|
|
298
|
-
expect(
|
|
299
|
-
expect(
|
|
295
|
+
expect(fooDashBar.kind).toBe(ts.SyntaxKind.PropertyDeclaration);
|
|
296
|
+
expect(fooDashBar.name.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
297
|
+
expect(fooDashBar.name.text).toBe('foo-bar');
|
|
298
|
+
expect(fooDashBar.type.kind).toBe(ts.SyntaxKind.StringLiteral);
|
|
299
|
+
expect(fooDashBar.type.text).toBe('foobar');
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
test('Invalid data type supplied (function)', () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/typescript-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Typescript support for Strapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"node": ">=18.0.0 <=22.x.x",
|
|
50
50
|
"npm": ">=6.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7d785703f52464577d077c4618cbe68b44f8a9cd"
|
|
53
53
|
}
|