inferred-types 0.19.0 → 0.22.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.
Files changed (133) hide show
  1. package/.eslintrc +36 -20
  2. package/.github/workflows/main.yml +34 -0
  3. package/.github/workflows/other.yml +15 -0
  4. package/.vscode/settings.json +10 -2
  5. package/dist/index.d.ts +403 -8538
  6. package/dist/index.js +35 -60
  7. package/dist/index.mjs +24 -48
  8. package/package.json +34 -23
  9. package/src/shared/valueTypes.ts +1 -1
  10. package/src/types/ExpandRecursively.ts +10 -1
  11. package/src/types/FunctionType.ts +1 -1
  12. package/src/types/SimplifyObject.ts +12 -0
  13. package/src/types/Transformer.ts +1 -1
  14. package/src/types/alphabetic/CamelCase.ts +1 -1
  15. package/src/types/alphabetic/CapFirstAlpha.ts +7 -3
  16. package/src/types/alphabetic/Dasherize.ts +8 -5
  17. package/src/types/alphabetic/KebabCase.ts +1 -1
  18. package/src/types/alphabetic/PascalCase.ts +3 -1
  19. package/src/types/alphabetic/SnakeCase.ts +8 -3
  20. package/src/types/dictionary/DictPartialApplication.ts +30 -0
  21. package/src/types/dictionary/DictPrependWithFn.ts +23 -0
  22. package/src/types/dictionary/DictReturnValues.ts +27 -0
  23. package/src/types/dictionary/RequireProps.ts +15 -0
  24. package/src/types/{type-conversion → dictionary}/SameKeys.ts +0 -0
  25. package/src/types/dictionary/index.ts +8 -3
  26. package/src/types/{props.ts → dictionary/props.ts} +1 -1
  27. package/src/types/functions/FinalReturn.ts +12 -0
  28. package/{on-hold/types → src/types/functions}/index.ts +4 -3
  29. package/src/types/index.ts +4 -3
  30. package/src/types/ruleset-types.ts +3 -3
  31. package/src/types/runtime.ts +18 -18
  32. package/src/types/string-literals/LeftWhitespace.ts +5 -2
  33. package/src/types/string-literals/RightWhitespace.ts +5 -2
  34. package/src/types/tuples/FirstKey.ts +3 -3
  35. package/src/types/tuples/FromDictArray.ts +5 -4
  36. package/src/types/type-conversion/index.ts +2 -5
  37. package/src/utility/api/api.ts +8 -7
  38. package/src/utility/createFnWithProps.ts +26 -1
  39. package/src/utility/dictionary/dictionaryTransform.ts +5 -4
  40. package/src/utility/dictionary/entries.ts +9 -5
  41. package/src/utility/dictionary/index.ts +2 -3
  42. package/src/utility/dictionary/kv/dictToKv.ts +5 -3
  43. package/src/utility/dictionary/kv/filterDictArray.ts +5 -7
  44. package/src/utility/dictionary/kv/kv.ts +8 -3
  45. package/src/utility/dictionary/kv/kvToDict.ts +3 -2
  46. package/src/utility/dictionary/mapValues.ts +8 -5
  47. package/src/utility/dictionary/strArrayToDict.ts +1 -2
  48. package/src/utility/keys.ts +8 -4
  49. package/src/utility/lists/groupBy.ts +2 -9
  50. package/src/utility/literals/arrayToObject.ts +29 -29
  51. package/src/utility/literals/defineType.ts +6 -6
  52. package/src/utility/literals/identity.ts +5 -2
  53. package/src/utility/literals/literal.ts +3 -3
  54. package/src/utility/ruleset.ts +11 -9
  55. package/src/utility/runtime/condition.ts +1 -1
  56. package/src/utility/runtime/conditions/isFalse.ts +2 -2
  57. package/src/utility/runtime/conditions/isFunction.ts +2 -2
  58. package/src/utility/runtime/conditions/isObject.ts +4 -1
  59. package/src/utility/runtime/conditions/isTrue.ts +1 -1
  60. package/src/utility/runtime/ifTypeOf.ts +1 -1
  61. package/src/utility/runtime/type.ts +3 -1
  62. package/src/utility/runtime/withValue.ts +5 -3
  63. package/src/utility/state/Configurator.ts +2 -2
  64. package/src/utility/state/FluentConfigurator.ts +2 -2
  65. package/src/utility/state/index.ts +2 -3
  66. package/tests/CamelCase-spec.ts +2 -0
  67. package/tests/ExplicitFunction-spec.ts +3 -2
  68. package/tests/IncludeAndRetain-spec.ts +7 -12
  69. package/tests/Includes-spec.ts +2 -0
  70. package/tests/KebabCase-spec.ts +2 -0
  71. package/tests/MutationIdentity-spec.ts +2 -1
  72. package/tests/PascalCase-spec.ts +2 -0
  73. package/tests/Pluralize-spec.ts +2 -0
  74. package/tests/SnakeCase-spec.ts +2 -0
  75. package/tests/Where.spec.ts +9 -10
  76. package/tests/arrayToKeyLookup-spec.ts +5 -5
  77. package/tests/arrayToObject-spec.ts +12 -8
  78. package/tests/constructor.spec.ts +2 -0
  79. package/tests/createFnWithProps.spec.ts +2 -2
  80. package/tests/defineType-spec.ts +17 -11
  81. package/tests/dictionary/DictPartialApplication.test.ts +43 -0
  82. package/tests/dictionary/DictReturnValues.test.ts +32 -0
  83. package/tests/dictionary/Get.spec.ts +5 -3
  84. package/tests/dictionary/PrependValuesWithFunction.ts +34 -0
  85. package/tests/dictionary/RequireProps.test.ts +21 -0
  86. package/tests/dictionaryTransform-spec.ts +3 -3
  87. package/tests/ifTypeOf-spec.ts +31 -20
  88. package/tests/kv/KeyValue-spec.ts +4 -4
  89. package/tests/kv/SameKeys-spec.ts +6 -9
  90. package/tests/kv/dict-to-kv-and-back.spec.ts +5 -4
  91. package/tests/kv/entries-spec.ts +8 -9
  92. package/tests/kv/keys.spec.ts +9 -19
  93. package/tests/kv/kv-spec.ts +4 -4
  94. package/tests/lists/UniqueForProp.spec.ts +3 -1
  95. package/tests/literal-spec.ts +5 -3
  96. package/tests/mapValues-spec.ts +5 -3
  97. package/tests/props-spec.ts +3 -2
  98. package/tests/runtime/condition.spec.ts +2 -1
  99. package/tests/runtime/type.spec.ts +4 -3
  100. package/tests/strArrayToDict-spec.ts +6 -6
  101. package/tests/string-literals/AllCaps.spec.ts +6 -15
  102. package/tests/string-literals/CamelCase.spec.ts +13 -32
  103. package/tests/string-literals/Dasherize.spec.ts +13 -31
  104. package/tests/string-literals/HasUppercase.spec.ts +6 -15
  105. package/tests/string-literals/PascalCase.spec.ts +13 -32
  106. package/tests/string-literals/SnakeCase.spec.ts +13 -32
  107. package/tests/string-literals/whitespace-capture.spec.ts +10 -28
  108. package/tests/tuples/TupleToUnion.spec.ts +3 -1
  109. package/tests/withValue.spec.ts +4 -3
  110. package/tsconfig.json +8 -19
  111. package/vitest.config.ts +13 -0
  112. package/jest.config.ts +0 -20
  113. package/on-hold/Builder/Builder.ts +0 -66
  114. package/on-hold/Builder/BuilderApi.ts +0 -21
  115. package/on-hold/Builder/IdentityToMutationApi.ts +0 -44
  116. package/on-hold/Builder/MutationToFluentApi.ts +0 -60
  117. package/on-hold/Builder/index.ts +0 -35
  118. package/on-hold/tests/Builder-spec.ts +0 -310
  119. package/on-hold/tests/RuleSet-spec.ts +0 -59
  120. package/on-hold/tests/ToFluent-spec.ts +0 -60
  121. package/on-hold/tests/api-spec.ts +0 -73
  122. package/on-hold/tests/data/builder-data.ts +0 -53
  123. package/on-hold/tests/filterDictArray-spec.ts +0 -50
  124. package/on-hold/tests/run-time-spec.ts +0 -44
  125. package/on-hold/type.ts +0 -20
  126. package/on-hold/types/object.ts +0 -19
  127. package/on-hold/types/prop.ts +0 -28
  128. package/on-hold/types/scalar.ts +0 -37
  129. package/src/types/dictionary/NotEmptyObject.ts +0 -9
  130. package/src/types/type-conversion/UnwrapValue.ts +0 -13
  131. package/src/types/type-conversion/WrapValue.ts +0 -15
  132. package/src/utility/dictionary/valuesOfProp.ts +0 -13
  133. package/src/utility/state/KeyStorage.ts +0 -23
@@ -1,19 +1,17 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { CamelCase } from "~/types";
4
+ import { CamelCase } from "src/types";
3
5
 
4
6
  const target = "twoThreeFour";
5
7
  type TARGET = typeof target;
6
8
 
7
9
  describe("CamelCase<T> type utility", () => {
8
-
9
10
  it("CamelCase<T> provides an identity to a CamelCased string", () => {
10
11
  type T1 = CamelCase<"TwoThreeFour">;
11
12
  type T2 = CamelCase<"\n TwoThreeFour ">;
12
13
 
13
- type cases = [
14
- Expect<Equal<T1, TARGET>>,
15
- Expect<Equal<T2, TARGET>>,
16
- ];
14
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
17
15
  const c: cases = [true, true];
18
16
  expect(c).toBe(c);
19
17
  });
@@ -21,9 +19,7 @@ describe("CamelCase<T> type utility", () => {
21
19
  it("CamelCase<T> transform snake_case type", () => {
22
20
  type T1 = CamelCase<"two_three_four">;
23
21
 
24
- type cases = [
25
- Expect<Equal<T1, TARGET>>
26
- ];
22
+ type cases = [Expect<Equal<T1, TARGET>>];
27
23
  const c: cases = [true];
28
24
  expect(c).toBe(c);
29
25
  });
@@ -32,10 +28,7 @@ describe("CamelCase<T> type utility", () => {
32
28
  type T1 = CamelCase<"twoThreeFour">;
33
29
  type T2 = CamelCase<" twoThreeFour \t">;
34
30
 
35
- type cases = [
36
- Expect<Equal<T1, TARGET>>,
37
- Expect<Equal<T2, TARGET>>,
38
- ];
31
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
39
32
  const c: cases = [true, true];
40
33
  expect(c).toBe(c);
41
34
  });
@@ -54,7 +47,7 @@ describe("CamelCase<T> type utility", () => {
54
47
  Expect<Equal<T3, "twoThreeFourFiveSix">>,
55
48
  Expect<Equal<T4, "twoThreeFourFiveSixSeven">>,
56
49
  Expect<Equal<T5, "twoThreeFourFiveSixSevenEight">>,
57
- Expect<Equal<T6, "twoThreeFourFiveSixSevenEightNineTenEleven">>,
50
+ Expect<Equal<T6, "twoThreeFourFiveSixSevenEightNineTenEleven">>
58
51
  ];
59
52
  const c: cases = [true, true, true, true, true, true];
60
53
  expect(c).toBe(c);
@@ -63,9 +56,7 @@ describe("CamelCase<T> type utility", () => {
63
56
  it("CamelCase<T> transforms interior space to CamelCased type", () => {
64
57
  type T1 = CamelCase<"two three four">;
65
58
 
66
- type cases = [
67
- Expect<Equal<T1, TARGET>>
68
- ];
59
+ type cases = [Expect<Equal<T1, TARGET>>];
69
60
  const c: cases = [true];
70
61
  expect(c).toBe(c);
71
62
  });
@@ -75,11 +66,7 @@ describe("CamelCase<T> type utility", () => {
75
66
  type T2 = CamelCase<"\n TWO_THREE_FOUR ">;
76
67
  type T3 = CamelCase<"\n TWO-THREE-FOUR ">;
77
68
 
78
- type cases = [
79
- Expect<Equal<T1, TARGET>>,
80
- Expect<Equal<T2, TARGET>>,
81
- Expect<Equal<T3, TARGET>>,
82
- ];
69
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
83
70
  const c: cases = [true, true, true];
84
71
  expect(c).toBe(c);
85
72
  });
@@ -88,10 +75,7 @@ describe("CamelCase<T> type utility", () => {
88
75
  type T1 = CamelCase<" one two three ">;
89
76
  type T2 = CamelCase<"\n one two three ">;
90
77
 
91
- type cases = [
92
- Expect<Equal<T1, "oneTwoThree">>,
93
- Expect<Equal<T2, "oneTwoThree">>,
94
- ];
78
+ type cases = [Expect<Equal<T1, "oneTwoThree">>, Expect<Equal<T2, "oneTwoThree">>];
95
79
  const c: cases = [true, true];
96
80
  expect(c).toBe(c);
97
81
  });
@@ -99,9 +83,7 @@ describe("CamelCase<T> type utility", () => {
99
83
  it("CamelCase<T> returns 'string' type when passed a non-literal string", () => {
100
84
  type T1 = CamelCase<string>;
101
85
 
102
- type cases = [
103
- Expect<Equal<T1, string>>,
104
- ];
86
+ type cases = [Expect<Equal<T1, string>>];
105
87
  const c: cases = [true];
106
88
  expect(c).toBe(c);
107
89
  });
@@ -119,10 +101,9 @@ describe("CamelCase<T> type utility", () => {
119
101
  Expect<Equal<T2, "oneTwoThreeFourFiveSixSevenEightNine">>,
120
102
  Expect<Equal<T3, "oneTwoThreeFourFiveSixSevenEightNine">>,
121
103
  Expect<Equal<T4, "oneTwoThreeFourFiveSixSevenEightNine">>,
122
- Expect<Equal<T5, "oneTwoThreeFourFiveSixSevenEightNine">>,
104
+ Expect<Equal<T5, "oneTwoThreeFourFiveSixSevenEightNine">>
123
105
  ];
124
106
  const c: cases = [true, true, true, true, true];
125
107
  expect(c).toBe(c);
126
108
  });
127
-
128
- });
109
+ });
@@ -1,19 +1,17 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { Dasherize } from "~/types";
4
+ import { Dasherize } from "src/types";
3
5
 
4
6
  const target = "two-three-four";
5
7
  type TARGET = typeof target;
6
8
 
7
9
  describe("Dasherize<T> type utility", () => {
8
-
9
10
  it("Dasherize<T> provides an identity to a dasherized string", () => {
10
11
  type T1 = Dasherize<"two-three-four">;
11
12
  type T2 = Dasherize<"\n two-three-four ">;
12
13
 
13
- type cases = [
14
- Expect<Equal<T1, TARGET>>,
15
- Expect<Equal<T2, TARGET>>,
16
- ];
14
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
17
15
  const c: cases = [true, true];
18
16
  expect(c).toBe(c);
19
17
  });
@@ -21,9 +19,7 @@ describe("Dasherize<T> type utility", () => {
21
19
  it("Dasherize<T> transform snake_case type", () => {
22
20
  type T1 = Dasherize<"two_three_four">;
23
21
 
24
- type cases = [
25
- Expect<Equal<T1, TARGET>>
26
- ];
22
+ type cases = [Expect<Equal<T1, TARGET>>];
27
23
  const c: cases = [true];
28
24
  expect(c).toBe(c);
29
25
  });
@@ -31,9 +27,7 @@ describe("Dasherize<T> type utility", () => {
31
27
  it("Dasherize<T> transforms PascalCase type", () => {
32
28
  type T1 = Dasherize<"TwoThreeFour">;
33
29
 
34
- type cases = [
35
- Expect<Equal<T1, TARGET>>
36
- ];
30
+ type cases = [Expect<Equal<T1, TARGET>>];
37
31
  const c: cases = [true];
38
32
  expect(c).toBe(c);
39
33
  });
@@ -51,7 +45,7 @@ describe("Dasherize<T> type utility", () => {
51
45
  Expect<Equal<T2, "two-three-four-five">>,
52
46
  Expect<Equal<T3, "two-three-four-five-six">>,
53
47
  Expect<Equal<T4, "two-three-four-five-six-seven">>,
54
- Expect<Equal<T5, "two-three-four-five-six-seven-eight">>,
48
+ Expect<Equal<T5, "two-three-four-five-six-seven-eight">>
55
49
  // Expect<Equal<T6, "two-three-four-five-six-seven-eight-nine">>,
56
50
  ];
57
51
  const c: cases = [true, true, true, true, true];
@@ -61,9 +55,7 @@ describe("Dasherize<T> type utility", () => {
61
55
  it("Dasherize<T> transforms interior space to dasherized type", () => {
62
56
  type T1 = Dasherize<"two three four">;
63
57
 
64
- type cases = [
65
- Expect<Equal<T1, TARGET>>
66
- ];
58
+ type cases = [Expect<Equal<T1, TARGET>>];
67
59
  const c: cases = [true];
68
60
  expect(c).toBe(c);
69
61
  });
@@ -73,11 +65,7 @@ describe("Dasherize<T> type utility", () => {
73
65
  type T2 = Dasherize<"\n TWO_THREE_FOUR ">;
74
66
  type T3 = Dasherize<"\n TWO-THREE-FOUR ">;
75
67
 
76
- type cases = [
77
- Expect<Equal<T1, TARGET>>,
78
- Expect<Equal<T2, TARGET>>,
79
- Expect<Equal<T3, TARGET>>,
80
- ];
68
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
81
69
  const c: cases = [true, true, true];
82
70
  expect(c).toBe(c);
83
71
  });
@@ -86,10 +74,7 @@ describe("Dasherize<T> type utility", () => {
86
74
  type T1 = Dasherize<" one two three ">;
87
75
  type T2 = Dasherize<"\n one two three ">;
88
76
 
89
- type cases = [
90
- Expect<Equal<T1, "one-two-three">>,
91
- Expect<Equal<T2, "one-two-three">>,
92
- ];
77
+ type cases = [Expect<Equal<T1, "one-two-three">>, Expect<Equal<T2, "one-two-three">>];
93
78
  const c: cases = [true, true];
94
79
  expect(c).toBe(c);
95
80
  });
@@ -97,9 +82,7 @@ describe("Dasherize<T> type utility", () => {
97
82
  it("Dasherize<T> returns 'string' type when passed a non-literal string", () => {
98
83
  type T1 = Dasherize<string>;
99
84
 
100
- type cases = [
101
- Expect<Equal<T1, string>>,
102
- ];
85
+ type cases = [Expect<Equal<T1, string>>];
103
86
  const c: cases = [true];
104
87
  expect(c).toBe(c);
105
88
  });
@@ -116,10 +99,9 @@ describe("Dasherize<T> type utility", () => {
116
99
  Expect<Equal<T2, "one-two-three-four-five-six-seven-eight-nine-ten">>,
117
100
  Expect<Equal<T3, "one-two-three-four-five-six-seven-eight-nine-ten">>,
118
101
  Expect<Equal<T4, "one-two-three-four-five-six-seven-eight-nine-ten">>,
119
- Expect<Equal<T5, "one-two-three-four-five-six-seven-eight-nine-ten">>,
102
+ Expect<Equal<T5, "one-two-three-four-five-six-seven-eight-nine-ten">>
120
103
  ];
121
104
  const c: cases = [true, true, true, true, true];
122
105
  expect(c).toBe(c);
123
106
  });
124
-
125
- });
107
+ });
@@ -1,18 +1,15 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { HasUppercase } from "~/types";
4
+ import { HasUppercase } from "src/types";
3
5
 
4
6
  describe("HasUppercase<T> type utility", () => {
5
-
6
7
  it("finds capitals where they exist", () => {
7
8
  type T1 = HasUppercase<"Yup">;
8
9
  type T2 = HasUppercase<"yUp">;
9
10
  type T3 = HasUppercase<"YUP">;
10
11
 
11
- type cases = [
12
- Expect<Equal<T1, true>>,
13
- Expect<Equal<T2, true>>,
14
- Expect<Equal<T3, true>>,
15
- ];
12
+ type cases = [Expect<Equal<T1, true>>, Expect<Equal<T2, true>>, Expect<Equal<T3, true>>];
16
13
  const c: cases = [true, true, true];
17
14
  expect(c).toBe(c);
18
15
  });
@@ -21,10 +18,7 @@ describe("HasUppercase<T> type utility", () => {
21
18
  type T1 = HasUppercase<"nope">;
22
19
  type T2 = HasUppercase<" noo nooo noooooooooooooo">;
23
20
 
24
- type cases = [
25
- Expect<Equal<T1, false>>,
26
- Expect<Equal<T2, false>>,
27
- ];
21
+ type cases = [Expect<Equal<T1, false>>, Expect<Equal<T2, false>>];
28
22
  const c: cases = [true, true];
29
23
  expect(c).toBe(c);
30
24
  });
@@ -32,11 +26,8 @@ describe("HasUppercase<T> type utility", () => {
32
26
  it("when passed a non literal string, returns 'unknown'", () => {
33
27
  type T1 = HasUppercase<string>;
34
28
 
35
- type cases = [
36
- Expect<Equal<T1, "unknown">>,
37
- ];
29
+ type cases = [Expect<Equal<T1, "unknown">>];
38
30
  const c: cases = [true];
39
31
  expect(c).toBe(c);
40
32
  });
41
-
42
33
  });
@@ -1,19 +1,17 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { PascalCase } from "~/types";
4
+ import { PascalCase } from "src/types";
3
5
 
4
6
  const target = "TwoThreeFour";
5
7
  type TARGET = typeof target;
6
8
 
7
9
  describe("PascalCase<T> type utility", () => {
8
-
9
10
  it("PascalCase<T> provides an identity to a PascalCased string", () => {
10
11
  type T1 = PascalCase<"TwoThreeFour">;
11
12
  type T2 = PascalCase<"\n TwoThreeFour ">;
12
13
 
13
- type cases = [
14
- Expect<Equal<T1, TARGET>>,
15
- Expect<Equal<T2, TARGET>>,
16
- ];
14
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
17
15
  const c: cases = [true, true];
18
16
  expect(c).toBe(c);
19
17
  });
@@ -21,9 +19,7 @@ describe("PascalCase<T> type utility", () => {
21
19
  it("PascalCase<T> transform snake_case type", () => {
22
20
  type T1 = PascalCase<"two_three_four">;
23
21
 
24
- type cases = [
25
- Expect<Equal<T1, TARGET>>
26
- ];
22
+ type cases = [Expect<Equal<T1, TARGET>>];
27
23
  const c: cases = [true];
28
24
  expect(c).toBe(c);
29
25
  });
@@ -32,10 +28,7 @@ describe("PascalCase<T> type utility", () => {
32
28
  type T1 = PascalCase<"twoThreeFour">;
33
29
  type T2 = PascalCase<" twoThreeFour \t">;
34
30
 
35
- type cases = [
36
- Expect<Equal<T1, TARGET>>,
37
- Expect<Equal<T2, TARGET>>,
38
- ];
31
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
39
32
  const c: cases = [true, true];
40
33
  expect(c).toBe(c);
41
34
  });
@@ -54,7 +47,7 @@ describe("PascalCase<T> type utility", () => {
54
47
  Expect<Equal<T3, "TwoThreeFourFiveSix">>,
55
48
  Expect<Equal<T4, "TwoThreeFourFiveSixSeven">>,
56
49
  Expect<Equal<T5, "TwoThreeFourFiveSixSevenEight">>,
57
- Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>,
50
+ Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>
58
51
  ];
59
52
  const c: cases = [true, true, true, true, true, true];
60
53
  expect(c).toBe(c);
@@ -63,9 +56,7 @@ describe("PascalCase<T> type utility", () => {
63
56
  it("PascalCase<T> transforms interior space to PascalCased type", () => {
64
57
  type T1 = PascalCase<"two three four">;
65
58
 
66
- type cases = [
67
- Expect<Equal<T1, TARGET>>
68
- ];
59
+ type cases = [Expect<Equal<T1, TARGET>>];
69
60
  const c: cases = [true];
70
61
  expect(c).toBe(c);
71
62
  });
@@ -75,11 +66,7 @@ describe("PascalCase<T> type utility", () => {
75
66
  type T2 = PascalCase<"\n TWO_THREE_FOUR ">;
76
67
  type T3 = PascalCase<"\n TWO-THREE-FOUR ">;
77
68
 
78
- type cases = [
79
- Expect<Equal<T1, TARGET>>,
80
- Expect<Equal<T2, TARGET>>,
81
- Expect<Equal<T3, TARGET>>,
82
- ];
69
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
83
70
  const c: cases = [true, true, true];
84
71
  expect(c).toBe(c);
85
72
  });
@@ -88,10 +75,7 @@ describe("PascalCase<T> type utility", () => {
88
75
  type T1 = PascalCase<" one two three ">;
89
76
  type T2 = PascalCase<"\n one two three ">;
90
77
 
91
- type cases = [
92
- Expect<Equal<T1, "OneTwoThree">>,
93
- Expect<Equal<T2, "OneTwoThree">>,
94
- ];
78
+ type cases = [Expect<Equal<T1, "OneTwoThree">>, Expect<Equal<T2, "OneTwoThree">>];
95
79
  const c: cases = [true, true];
96
80
  expect(c).toBe(c);
97
81
  });
@@ -99,9 +83,7 @@ describe("PascalCase<T> type utility", () => {
99
83
  it("PascalCase<T> returns 'string' type when passed a non-literal string", () => {
100
84
  type T1 = PascalCase<string>;
101
85
 
102
- type cases = [
103
- Expect<Equal<T1, string>>,
104
- ];
86
+ type cases = [Expect<Equal<T1, string>>];
105
87
  const c: cases = [true];
106
88
  expect(c).toBe(c);
107
89
  });
@@ -119,10 +101,9 @@ describe("PascalCase<T> type utility", () => {
119
101
  Expect<Equal<T2, "OneTwoThreeFourFiveSixSevenEightNine">>,
120
102
  Expect<Equal<T3, "OneTwoThreeFourFiveSixSevenEightNine">>,
121
103
  Expect<Equal<T4, "OneTwoThreeFourFiveSixSevenEightNine">>,
122
- Expect<Equal<T5, "OneTwoThreeFourFiveSixSevenEightNine">>,
104
+ Expect<Equal<T5, "OneTwoThreeFourFiveSixSevenEightNine">>
123
105
  ];
124
106
  const c: cases = [true, true, true, true, true];
125
107
  expect(c).toBe(c);
126
108
  });
127
-
128
- });
109
+ });
@@ -1,19 +1,17 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { SnakeCase } from "~/types";
4
+ import { SnakeCase } from "src/types";
3
5
 
4
6
  const target = "two_three_four";
5
7
  type TARGET = typeof target;
6
8
 
7
9
  describe("SnakeCase<T> type utility", () => {
8
-
9
10
  it("SnakeCase<T> provides an identity to a SnakeCased string", () => {
10
11
  type T1 = SnakeCase<"TwoThreeFour">;
11
12
  type T2 = SnakeCase<"\n TwoThreeFour ">;
12
13
 
13
- type cases = [
14
- Expect<Equal<T1, TARGET>>,
15
- Expect<Equal<T2, TARGET>>,
16
- ];
14
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
17
15
  const c: cases = [true, true];
18
16
  expect(c).toBe(c);
19
17
  });
@@ -21,9 +19,7 @@ describe("SnakeCase<T> type utility", () => {
21
19
  it("SnakeCase<T> transform snake_case type", () => {
22
20
  type T1 = SnakeCase<"two_three_four">;
23
21
 
24
- type cases = [
25
- Expect<Equal<T1, TARGET>>
26
- ];
22
+ type cases = [Expect<Equal<T1, TARGET>>];
27
23
  const c: cases = [true];
28
24
  expect(c).toBe(c);
29
25
  });
@@ -32,10 +28,7 @@ describe("SnakeCase<T> type utility", () => {
32
28
  type T1 = SnakeCase<"twoThreeFour">;
33
29
  type T2 = SnakeCase<" twoThreeFour \t">;
34
30
 
35
- type cases = [
36
- Expect<Equal<T1, TARGET>>,
37
- Expect<Equal<T2, TARGET>>,
38
- ];
31
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>];
39
32
  const c: cases = [true, true];
40
33
  expect(c).toBe(c);
41
34
  });
@@ -53,7 +46,7 @@ describe("SnakeCase<T> type utility", () => {
53
46
  Expect<Equal<T2, "two_three_four_five">>,
54
47
  Expect<Equal<T3, "two_three_four_five_six">>,
55
48
  Expect<Equal<T4, "two_three_four_five_six_seven">>,
56
- Expect<Equal<T5, "two_three_four_five_six_seven_eight">>,
49
+ Expect<Equal<T5, "two_three_four_five_six_seven_eight">>
57
50
  // Expect<Equal<T6, "TwoThreeFourFiveSixSevenEightNineTenEleven">>,
58
51
  ];
59
52
  const c: cases = [true, true, true, true, true];
@@ -63,9 +56,7 @@ describe("SnakeCase<T> type utility", () => {
63
56
  it("SnakeCase<T> transforms interior space to SnakeCased type", () => {
64
57
  type T1 = SnakeCase<"two three four">;
65
58
 
66
- type cases = [
67
- Expect<Equal<T1, TARGET>>
68
- ];
59
+ type cases = [Expect<Equal<T1, TARGET>>];
69
60
  const c: cases = [true];
70
61
  expect(c).toBe(c);
71
62
  });
@@ -75,11 +66,7 @@ describe("SnakeCase<T> type utility", () => {
75
66
  type T2 = SnakeCase<"\n TWO_THREE_FOUR ">;
76
67
  type T3 = SnakeCase<"\n TWO-THREE-FOUR ">;
77
68
 
78
- type cases = [
79
- Expect<Equal<T1, TARGET>>,
80
- Expect<Equal<T2, TARGET>>,
81
- Expect<Equal<T3, TARGET>>,
82
- ];
69
+ type cases = [Expect<Equal<T1, TARGET>>, Expect<Equal<T2, TARGET>>, Expect<Equal<T3, TARGET>>];
83
70
  const c: cases = [true, true, true];
84
71
  expect(c).toBe(c);
85
72
  });
@@ -88,10 +75,7 @@ describe("SnakeCase<T> type utility", () => {
88
75
  type T1 = SnakeCase<" one two three ">;
89
76
  type T2 = SnakeCase<"\n one two three ">;
90
77
 
91
- type cases = [
92
- Expect<Equal<T1, "one_two_three">>,
93
- Expect<Equal<T2, "one_two_three">>,
94
- ];
78
+ type cases = [Expect<Equal<T1, "one_two_three">>, Expect<Equal<T2, "one_two_three">>];
95
79
  const c: cases = [true, true];
96
80
  expect(c).toBe(c);
97
81
  });
@@ -99,9 +83,7 @@ describe("SnakeCase<T> type utility", () => {
99
83
  it("SnakeCase<T> returns 'string' type when passed a non-literal string", () => {
100
84
  type T1 = SnakeCase<string>;
101
85
 
102
- type cases = [
103
- Expect<Equal<T1, string>>,
104
- ];
86
+ type cases = [Expect<Equal<T1, string>>];
105
87
  const c: cases = [true];
106
88
  expect(c).toBe(c);
107
89
  });
@@ -119,10 +101,9 @@ describe("SnakeCase<T> type utility", () => {
119
101
  Expect<Equal<T2, "one_two_three_four_five_six_seven_eight_nine">>,
120
102
  Expect<Equal<T3, "one_two_three_four_five_six_seven_eight_nine">>,
121
103
  Expect<Equal<T4, "one_two_three_four_five_six_seven_eight_nine">>,
122
- Expect<Equal<T5, "one_two_three_four_five_six_seven_eight_nine">>,
104
+ Expect<Equal<T5, "one_two_three_four_five_six_seven_eight_nine">>
123
105
  ];
124
106
  const c: cases = [true, true, true, true, true];
125
107
  expect(c).toBe(c);
126
108
  });
127
-
128
- });
109
+ });
@@ -1,16 +1,14 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { LeftWhitespace, RightWhitespace } from "~/types";
4
+ import { LeftWhitespace, RightWhitespace } from "src/types";
3
5
 
4
6
  describe("LeftWhitespace<T> utility", () => {
5
-
6
7
  it("no whitespace results in empty string literal", () => {
7
8
  type T1 = LeftWhitespace<"foobar">;
8
9
  type T2 = LeftWhitespace<"foobar \n">;
9
10
 
10
- type cases = [
11
- Expect<Equal<T1, "">>,
12
- Expect<Equal<T2, "">>,
13
- ];
11
+ type cases = [Expect<Equal<T1, "">>, Expect<Equal<T2, "">>];
14
12
  const c: cases = [true, true];
15
13
  expect(c).toBe(c);
16
14
  });
@@ -19,10 +17,7 @@ describe("LeftWhitespace<T> utility", () => {
19
17
  type T1 = LeftWhitespace<" foobar">;
20
18
  type T2 = LeftWhitespace<"\n\t foobar \n">;
21
19
 
22
- type cases = [
23
- Expect<Equal<T1, " ">>,
24
- Expect<Equal<T2, "\n\t ">>,
25
- ];
20
+ type cases = [Expect<Equal<T1, " ">>, Expect<Equal<T2, "\n\t ">>];
26
21
  const c: cases = [true, true];
27
22
  expect(c).toBe(c);
28
23
  });
@@ -30,25 +25,18 @@ describe("LeftWhitespace<T> utility", () => {
30
25
  it("a 'string' type passed in returns a string", () => {
31
26
  type T1 = LeftWhitespace<string>;
32
27
 
33
- type cases = [
34
- Expect<Equal<T1, string>>,
35
- ];
28
+ type cases = [Expect<Equal<T1, string>>];
36
29
  const c: cases = [true];
37
30
  expect(c).toBe(c);
38
31
  });
39
-
40
32
  });
41
33
 
42
34
  describe("RightWhitespace<T> utility", () => {
43
-
44
35
  it("no whitespace results in empty string literal", () => {
45
36
  type T1 = RightWhitespace<"foobar">;
46
37
  type T2 = RightWhitespace<"\n\tfoobar">;
47
38
 
48
- type cases = [
49
- Expect<Equal<T1, "">>,
50
- Expect<Equal<T2, "">>,
51
- ];
39
+ type cases = [Expect<Equal<T1, "">>, Expect<Equal<T2, "">>];
52
40
  const c: cases = [true, true];
53
41
  expect(c).toBe(c);
54
42
  });
@@ -57,10 +45,7 @@ describe("RightWhitespace<T> utility", () => {
57
45
  type T1 = RightWhitespace<"foobar ">;
58
46
  type T2 = RightWhitespace<"\n\t foobar \n">;
59
47
 
60
- type cases = [
61
- Expect<Equal<T1, " ">>,
62
- Expect<Equal<T2, " \n">>,
63
- ];
48
+ type cases = [Expect<Equal<T1, " ">>, Expect<Equal<T2, " \n">>];
64
49
  const c: cases = [true, true];
65
50
  expect(c).toBe(c);
66
51
  });
@@ -68,11 +53,8 @@ describe("RightWhitespace<T> utility", () => {
68
53
  it("a 'string' type passed in returns a string", () => {
69
54
  type T1 = RightWhitespace<string>;
70
55
 
71
- type cases = [
72
- Expect<Equal<T1, string>>,
73
- ];
56
+ type cases = [Expect<Equal<T1, string>>];
74
57
  const c: cases = [true];
75
58
  expect(c).toBe(c);
76
59
  });
77
-
78
- });
60
+ });
@@ -1,4 +1,6 @@
1
- import { TupleToUnion } from "~/types";
1
+ import { describe, it, expect } from "vitest";
2
+
3
+ import { TupleToUnion } from "src/types";
2
4
  import { Expect, Equal } from "@type-challenges/utils";
3
5
 
4
6
  describe("TupleToUnion<T> type utility", () => {
@@ -1,7 +1,8 @@
1
- import { createFnWithProps, type, withValue } from "~/utility";
1
+ import { describe, it, expect } from "vitest";
2
2
  import type { Expect, Equal } from "@type-challenges/utils";
3
- import { WithValue } from "~/types/props";
4
- import { FunctionType } from "~/types";
3
+
4
+ import { createFnWithProps, type, withValue } from "../src/utility";
5
+ import { FunctionType, WithValue } from "../src";
5
6
 
6
7
  describe("withValue()() utility", () => {
7
8
  it("type reduction with WithValue<T> works as expected", () => {
package/tsconfig.json CHANGED
@@ -3,37 +3,26 @@
3
3
  "module": "ESNEXT",
4
4
  "target": "ESNEXT",
5
5
  "moduleResolution": "node",
6
-
7
6
  "sourceMap": true,
8
7
  "noEmit": true,
9
8
  "incremental": true,
10
9
  "resolveJsonModule": true,
11
-
12
10
  "strict": true,
13
11
  "skipLibCheck": true,
14
12
  "noUnusedLocals": true,
15
13
  "noUnusedParameters": true,
16
14
  "noImplicitReturns": true,
17
15
  "allowSyntheticDefaultImports": true,
18
-
19
- "lib": ["ES2020"],
20
-
16
+ "lib": [
17
+ "ES2020"
18
+ ],
21
19
  "baseUrl": ".",
22
20
  "declaration": true,
23
21
  "outDir": "dist",
24
22
  "tsBuildInfoFile": ".tsbuildinfo",
25
-
26
- "paths": {
27
- "~/*": ["src/*"],
28
- "/~/*": ["src/*"]
29
- },
30
- "plugins": [
31
- // Transform paths in output .js files
32
- { "transform": "typescript-transform-paths" },
33
-
34
- // Transform paths in output .d.ts files (Include this line if you output declarations files)
35
- { "transform": "typescript-transform-paths", "afterDeclarations": true }
36
- ]
37
23
  },
38
- "include": ["src", "tests"]
39
- }
24
+ "include": [
25
+ "src",
26
+ "tests"
27
+ ]
28
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="vitest" />
2
+ import { defineConfig } from "vite";
3
+
4
+ // used for testing, library code uses TSUP to build exports
5
+ export default defineConfig({
6
+ test: {
7
+ dir: "tests",
8
+ api: {
9
+ host: "0.0.0.0",
10
+ },
11
+ },
12
+ plugins: [],
13
+ });