inferred-types 0.20.0 → 0.22.5

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 (161) 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 +426 -8547
  6. package/dist/index.js +57 -76
  7. package/dist/index.mjs +47 -63
  8. package/package.json +38 -26
  9. package/src/Mutation/index.ts +6 -29
  10. package/src/index.ts +6 -29
  11. package/src/shared/index.ts +6 -29
  12. package/src/shared/valueTypes.ts +1 -1
  13. package/src/types/ExpandRecursively.ts +10 -1
  14. package/src/types/Keys.ts +10 -6
  15. package/src/types/SimplifyObject.ts +12 -0
  16. package/src/types/Transformer.ts +1 -1
  17. package/src/types/alphabetic/CamelCase.ts +2 -2
  18. package/src/types/alphabetic/CapFirstAlpha.ts +7 -3
  19. package/src/types/alphabetic/Dasherize.ts +8 -5
  20. package/src/types/alphabetic/KebabCase.ts +1 -1
  21. package/src/types/alphabetic/PascalCase.ts +3 -1
  22. package/src/types/alphabetic/SnakeCase.ts +8 -3
  23. package/src/types/alphabetic/alpha-characters.ts +33 -9
  24. package/src/types/alphabetic/index.ts +6 -29
  25. package/src/types/dictionary/DictChangeValue.ts +26 -0
  26. package/src/types/dictionary/DictPartialApplication.ts +30 -0
  27. package/src/types/dictionary/DictPrependWithFn.ts +23 -0
  28. package/src/types/dictionary/DictReturnValues.ts +27 -0
  29. package/src/types/dictionary/MutableProps.ts +19 -0
  30. package/src/types/dictionary/RequireProps.ts +15 -0
  31. package/src/types/{type-conversion → dictionary}/SameKeys.ts +0 -0
  32. package/src/types/dictionary/index.ts +13 -30
  33. package/src/types/{props.ts → dictionary/props.ts} +2 -2
  34. package/src/types/fluent/index.ts +6 -29
  35. package/src/types/functions/FinalReturn.ts +12 -0
  36. package/src/types/functions/index.ts +12 -0
  37. package/src/types/index.ts +8 -30
  38. package/src/types/kv/index.ts +6 -29
  39. package/src/types/lists/index.ts +6 -29
  40. package/src/types/ruleset-types.ts +3 -3
  41. package/src/types/runtime.ts +18 -18
  42. package/src/types/string-literals/LeftWhitespace.ts +5 -2
  43. package/src/types/string-literals/RightWhitespace.ts +5 -2
  44. package/src/types/string-literals/index.ts +6 -29
  45. package/src/types/tuples/FirstKey.ts +3 -3
  46. package/src/types/tuples/FromDictArray.ts +5 -4
  47. package/src/types/tuples/index.ts +6 -29
  48. package/src/types/type-conversion/index.ts +6 -32
  49. package/src/utility/api/api.ts +8 -7
  50. package/src/utility/api/index.ts +6 -29
  51. package/src/utility/dictionary/defineProperties.ts +35 -0
  52. package/src/utility/dictionary/dictionaryTransform.ts +5 -4
  53. package/src/utility/dictionary/entries.ts +9 -5
  54. package/src/utility/dictionary/index.ts +7 -30
  55. package/src/utility/dictionary/kv/dictToKv.ts +5 -3
  56. package/src/utility/dictionary/kv/filterDictArray.ts +5 -7
  57. package/src/utility/dictionary/kv/index.ts +6 -29
  58. package/src/utility/dictionary/kv/kv.ts +8 -3
  59. package/src/utility/dictionary/kv/kvToDict.ts +3 -2
  60. package/src/utility/dictionary/mapValues.ts +8 -5
  61. package/src/utility/dictionary/strArrayToDict.ts +1 -2
  62. package/src/utility/errors/ReadOnlyViolation.ts +3 -0
  63. package/src/utility/errors/index.ts +12 -0
  64. package/src/utility/index.ts +7 -29
  65. package/src/utility/keys.ts +8 -4
  66. package/src/utility/lists/groupBy.ts +2 -9
  67. package/src/utility/lists/index.ts +6 -29
  68. package/src/utility/literals/arrayToObject.ts +29 -29
  69. package/src/utility/literals/defineType.ts +6 -6
  70. package/src/utility/literals/identity.ts +5 -2
  71. package/src/utility/literals/index.ts +6 -29
  72. package/src/utility/literals/literal.ts +3 -3
  73. package/src/utility/map-reduce/index.ts +6 -29
  74. package/src/utility/modelling/index.ts +6 -29
  75. package/src/utility/ruleset.ts +11 -9
  76. package/src/utility/runtime/condition.ts +1 -1
  77. package/src/utility/runtime/conditions/index.ts +6 -30
  78. package/src/utility/runtime/conditions/isFalse.ts +2 -2
  79. package/src/utility/runtime/conditions/isFunction.ts +2 -2
  80. package/src/utility/runtime/conditions/isObject.ts +4 -1
  81. package/src/utility/runtime/conditions/isTrue.ts +1 -1
  82. package/src/utility/runtime/ifTypeOf.ts +5 -4
  83. package/src/utility/runtime/index.ts +6 -29
  84. package/src/utility/runtime/type.ts +3 -1
  85. package/src/utility/runtime/withValue.ts +5 -3
  86. package/src/utility/state/Configurator.ts +2 -2
  87. package/src/utility/state/FluentConfigurator.ts +2 -2
  88. package/src/utility/state/index.ts +6 -30
  89. package/tests/CamelCase-spec.ts +2 -0
  90. package/tests/ExplicitFunction-spec.ts +3 -2
  91. package/tests/IncludeAndRetain-spec.ts +7 -12
  92. package/tests/Includes-spec.ts +2 -0
  93. package/tests/KebabCase-spec.ts +2 -0
  94. package/tests/MutationIdentity-spec.ts +2 -1
  95. package/tests/PascalCase-spec.ts +2 -0
  96. package/tests/Pluralize-spec.ts +2 -0
  97. package/tests/SnakeCase-spec.ts +2 -0
  98. package/tests/Where.spec.ts +9 -10
  99. package/tests/arrayToKeyLookup-spec.ts +5 -5
  100. package/tests/arrayToObject-spec.ts +12 -8
  101. package/tests/constructor.spec.ts +2 -0
  102. package/tests/createFnWithProps.spec.ts +2 -2
  103. package/tests/data/index.ts +6 -29
  104. package/tests/defineType-spec.ts +17 -11
  105. package/tests/dictionary/DictChangeValue.test.ts +30 -0
  106. package/tests/dictionary/DictPartialApplication.test.ts +43 -0
  107. package/tests/dictionary/DictReturnValues.test.ts +36 -0
  108. package/tests/dictionary/Get.spec.ts +5 -3
  109. package/tests/dictionary/MutableProps.test.ts +30 -0
  110. package/tests/dictionary/PrependValuesWithFunction.ts +34 -0
  111. package/tests/dictionary/RequireProps.test.ts +21 -0
  112. package/tests/dictionaryTransform-spec.ts +3 -3
  113. package/tests/ifTypeOf-spec.ts +31 -20
  114. package/tests/kv/KeyValue-spec.ts +4 -4
  115. package/tests/kv/SameKeys-spec.ts +6 -9
  116. package/tests/kv/dict-to-kv-and-back.spec.ts +5 -4
  117. package/tests/kv/entries-spec.ts +8 -9
  118. package/tests/kv/keys.spec.ts +9 -19
  119. package/tests/kv/kv-spec.ts +4 -4
  120. package/tests/lists/UniqueForProp.spec.ts +3 -1
  121. package/tests/literal-spec.ts +5 -3
  122. package/tests/mapValues-spec.ts +5 -3
  123. package/tests/props-spec.ts +3 -2
  124. package/tests/runtime/condition.spec.ts +2 -1
  125. package/tests/runtime/type.spec.ts +4 -3
  126. package/tests/strArrayToDict-spec.ts +6 -6
  127. package/tests/string-literals/AllCaps.spec.ts +6 -15
  128. package/tests/string-literals/CamelCase.spec.ts +13 -32
  129. package/tests/string-literals/Dasherize.spec.ts +13 -31
  130. package/tests/string-literals/HasUppercase.spec.ts +6 -15
  131. package/tests/string-literals/PascalCase.spec.ts +13 -32
  132. package/tests/string-literals/SnakeCase.spec.ts +13 -32
  133. package/tests/string-literals/whitespace-capture.spec.ts +10 -28
  134. package/tests/tuples/TupleToUnion.spec.ts +3 -1
  135. package/tests/withValue.spec.ts +4 -3
  136. package/tsconfig.json +8 -19
  137. package/vitest.config.ts +13 -0
  138. package/jest.config.ts +0 -20
  139. package/on-hold/Builder/Builder.ts +0 -66
  140. package/on-hold/Builder/BuilderApi.ts +0 -21
  141. package/on-hold/Builder/IdentityToMutationApi.ts +0 -44
  142. package/on-hold/Builder/MutationToFluentApi.ts +0 -60
  143. package/on-hold/Builder/index.ts +0 -35
  144. package/on-hold/tests/Builder-spec.ts +0 -310
  145. package/on-hold/tests/RuleSet-spec.ts +0 -59
  146. package/on-hold/tests/ToFluent-spec.ts +0 -60
  147. package/on-hold/tests/api-spec.ts +0 -73
  148. package/on-hold/tests/data/builder-data.ts +0 -53
  149. package/on-hold/tests/filterDictArray-spec.ts +0 -50
  150. package/on-hold/tests/run-time-spec.ts +0 -44
  151. package/on-hold/type.ts +0 -20
  152. package/on-hold/types/index.ts +0 -34
  153. package/on-hold/types/object.ts +0 -19
  154. package/on-hold/types/prop.ts +0 -28
  155. package/on-hold/types/scalar.ts +0 -37
  156. package/src/types/dictionary/NotEmptyObject.ts +0 -9
  157. package/src/types/type-conversion/UnwrapValue.ts +0 -13
  158. package/src/types/type-conversion/WrapValue.ts +0 -15
  159. package/src/utility/dictionary/valuesOfProp.ts +0 -13
  160. package/src/utility/runtime/conditions/isLiteral.ts +0 -7
  161. package/src/utility/state/KeyStorage.ts +0 -23
@@ -1,4 +1,4 @@
1
- import { Narrowable } from "~/types";
1
+ import { Narrowable } from "src/types/Narrowable";
2
2
 
3
3
  export type Condition<TInput extends Narrowable, TResult extends boolean> = (
4
4
  input: TInput
@@ -1,15 +1,14 @@
1
1
  // #autoindex
2
2
 
3
- // #region autoindexed files
4
- // index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
5
- // hash-code: a3788912
3
+ // #region auto-indexed files
4
+ // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
5
+ // hash-code: 4324574d
6
6
 
7
7
  // file exports
8
8
  export * from "./isArray";
9
9
  export * from "./isBoolean";
10
10
  export * from "./isFalse";
11
11
  export * from "./isFunction";
12
- export * from "./isLiteral";
13
12
  export * from "./isNull";
14
13
  export * from "./isNumber";
15
14
  export * from "./isObject";
@@ -18,30 +17,7 @@ export * from "./isSymbol";
18
17
  export * from "./isTrue";
19
18
  export * from "./isUndefined";
20
19
 
21
- // #endregion
20
+ // #endregion auto-indexed files
22
21
 
23
- // This file was created by running: "dd autoindex"; it assumes you have
24
- // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
25
- //
26
- // By default it assumes that exports are named exports but this can be changed by
27
- // adding a modifier to the '// #autoindex' syntax:
28
- //
29
- // - autoindex:named same as default, exports "named symbols"
30
- // - autoindex:default assumes each file is exporting a default export and
31
- // converts the default export to the name of the file
32
- // - autoindex:offset assumes files export "named symbols" but that each
33
- // file's symbols should be offset by the file's name
34
- //
35
- // You may also exclude certain files or directories by adding it to the
36
- // autoindex command. As an example:
37
- //
38
- // - autoindex:named, exclude: foo,bar,baz
39
- //
40
- // Inversely, if you state a file to be an "orphan" then autoindex files
41
- // below this file will not reference this autoindex file:
42
- //
43
- // - autoindex:named, orphan
44
- //
45
- // All content outside the "// #region" section in this file will be
46
- // preserved in situations where you need to do something paricularly awesome.
47
- // Keep on being awesome.
22
+ // see https://github.com/inocan-group/do-devops/docs/autoindex.md
23
+ // for more info
@@ -1,5 +1,5 @@
1
- import { Narrowable } from "~/types";
2
- import { IsBoolean } from "~/utility";
1
+ import { Narrowable } from "src/types/Narrowable";
2
+ import { IsBoolean } from "./isBoolean";
3
3
 
4
4
  export type IsFalse<T extends Narrowable> = IsBoolean<T> extends true
5
5
  ? // is a boolean
@@ -1,4 +1,4 @@
1
- import { FunctionType } from "~/types";
1
+ import { FunctionType } from "src/types/FunctionType";
2
2
 
3
3
  export type IsFunction<T> = T extends FunctionType ? true : false;
4
4
 
@@ -11,7 +11,7 @@ export type IsFunction<T> = T extends FunctionType ? true : false;
11
11
  * ```
12
12
  *
13
13
  * Note: the runtime `typeof [variable]` will correctly say "function" when a function is
14
- * encounted but if that function also has object types defined then the type will be a big
14
+ * encountered but if that function also has object types defined then the type will be a big
15
15
  * and ugly union type. This function will give you a proper boolean value in both cases.
16
16
  */
17
17
  export function isFunction<T extends unknown>(input: T): IsFunction<T> {
@@ -1,4 +1,7 @@
1
- import { FunctionType, Mutable, Narrowable, Not } from "~/types";
1
+ import { FunctionType } from "src/types/FunctionType";
2
+ import { Mutable } from "src/types/Mutable";
3
+ import { Narrowable } from "src/types/Narrowable";
4
+ import { Not } from "src/types/Not";
2
5
 
3
6
  export type IsObject<T> = Mutable<T> extends Record<string, any>
4
7
  ? // an object of some type
@@ -1,4 +1,4 @@
1
- import { Narrowable } from "~/types";
1
+ import { Narrowable } from "src/types/Narrowable";
2
2
  import type { IsBoolean } from "./isBoolean";
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Narrowable } from "~/types/Narrowable";
1
+ import { Narrowable } from "src/types/Narrowable";
2
2
  import { keys } from "../keys";
3
3
 
4
4
  function runtimeExtendsCheck<TValue extends any, TBase extends any>(
@@ -29,10 +29,11 @@ function runtimeExtendsCheck<TValue extends any, TBase extends any>(
29
29
  case "object":
30
30
  if (val === null && base === null) {
31
31
  return true as TValue extends TBase ? true : false;
32
+ } else {
33
+ return keys(base as object).every((i) =>
34
+ runtimeExtendsCheck((val as TValue)[i], base[i], narrow)
35
+ ) as TValue extends TBase ? true : false;
32
36
  }
33
- return keys(base as object).every((i) =>
34
- runtimeExtendsCheck(val[i], base[i], narrow)
35
- ) as TValue extends TBase ? true : false;
36
37
  }
37
38
  }
38
39
 
@@ -1,7 +1,7 @@
1
1
  // #autoindex
2
- // #region autoindexed files
3
- // index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
4
- // hash-code: 91796b6
2
+ // #region auto-indexed files
3
+ // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
4
+ // hash-code: 687852c8
5
5
 
6
6
  // file exports
7
7
  export * from "./condition";
@@ -11,30 +11,7 @@ export * from "./withValue";
11
11
  // directory exports
12
12
  export * from "./conditions/index";
13
13
 
14
- // #endregion
14
+ // #endregion auto-indexed files
15
15
 
16
- // This file was created by running: "dd autoindex"; it assumes you have
17
- // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
18
- //
19
- // By default it assumes that exports are named exports but this can be changed by
20
- // adding a modifier to the '// #autoindex' syntax:
21
- //
22
- // - autoindex:named same as default, exports "named symbols"
23
- // - autoindex:default assumes each file is exporting a default export and
24
- // converts the default export to the name of the file
25
- // - autoindex:offset assumes files export "named symbols" but that each
26
- // file's symbols should be offset by the file's name
27
- //
28
- // You may also exclude certain files or directories by adding it to the
29
- // autoindex command. As an example:
30
- //
31
- // - autoindex:named, exclude: foo,bar,baz
32
- //
33
- // Inversely, if you state a file to be an "orphan" then autoindex files
34
- // below this file will not reference this autoindex file:
35
- //
36
- // - autoindex:named, orphan
37
- //
38
- // All content outside the "// #region" section in this file will be
39
- // preserved in situations where you need to do something paricularly awesome.
40
- // Keep on being awesome.
16
+ // see https://github.com/inocan-group/do-devops/docs/autoindex.md
17
+ // for more info
@@ -1,4 +1,6 @@
1
- import { FunctionType, Narrowable, TypeGuard } from "~/types";
1
+ import { FunctionType } from "src/types/FunctionType";
2
+ import { Narrowable } from "src/types/Narrowable";
3
+ import { TypeGuard } from "src/types/TypeGuard";
2
4
  import {
3
5
  isString,
4
6
  isBoolean,
@@ -1,8 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
 
3
- import { ExpandRecursively, Narrowable, WithValue } from "~/types";
4
- import { entries } from "~/utility/dictionary";
5
- import { type, TypeDefinition } from "~/utility/runtime";
3
+ import { WithValue } from "src/types/dictionary";
4
+ import { ExpandRecursively } from "src/types/ExpandRecursively";
5
+ import { Narrowable } from "src/types/Narrowable";
6
+ import { entries } from "../dictionary/entries";
7
+ import { type, TypeDefinition } from "./type";
6
8
 
7
9
  /**
8
10
  * **withValue**
@@ -1,4 +1,5 @@
1
- /* eslint-disable unicorn/consistent-function-scoping */
1
+ import { ExpandRecursively } from "src/types/ExpandRecursively";
2
+
2
3
  type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
3
4
  function omit<T extends {}, K extends Array<keyof T>>(obj: T, ...removals: K) {
4
5
  const untyped = removals as Array<unknown>;
@@ -8,7 +9,6 @@ function omit<T extends {}, K extends Array<keyof T>>(obj: T, ...removals: K) {
8
9
  >;
9
10
  }
10
11
 
11
- import { ExpandRecursively } from "~/types";
12
12
  export interface IConfigurator<C = {}> {
13
13
  set<V, K extends string, KV = { [U in K]: V }>(
14
14
  key: K,
@@ -1,4 +1,4 @@
1
- import type { ExpandRecursively } from "~/types";
1
+ import { ExpandRecursively } from "src/types/ExpandRecursively";
2
2
 
3
3
  export interface IFluentConfigurator<C> {
4
4
  /**
@@ -28,7 +28,7 @@ export function FluentConfigurator<I>(initial: I = {} as I) {
28
28
  const api = <C>(current: C): IFluentConfigurator<C> => {
29
29
  return {
30
30
  set<V, K extends string, KV = { [U in K]: V }>(key: K, value: V) {
31
- const keyValue = ({ [key]: value as V } as unknown) as KV;
31
+ const keyValue = { [key]: value as V } as unknown as KV;
32
32
  const updated = { ...keyValue, ...current };
33
33
 
34
34
  return api<C & KV>(updated);
@@ -1,37 +1,13 @@
1
1
  // #autoindex
2
- // #region autoindexed files
3
- // index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
4
- // hash-code: fd5dfde8
2
+ // #region auto-indexed files
3
+ // index last changed at: 8th Aug, 2022, 09:51 AM ( GMT-7 )
4
+ // hash-code: 397c607b
5
5
 
6
6
  // file exports
7
7
  export * from "./Configurator";
8
8
  export * from "./FluentConfigurator";
9
- export * from "./KeyStorage";
10
9
 
11
- // #endregion
10
+ // #endregion auto-indexed files
12
11
 
13
- // This file was created by running: "dd autoindex"; it assumes you have
14
- // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
15
- //
16
- // By default it assumes that exports are named exports but this can be changed by
17
- // adding a modifier to the '// #autoindex' syntax:
18
- //
19
- // - autoindex:named same as default, exports "named symbols"
20
- // - autoindex:default assumes each file is exporting a default export and
21
- // converts the default export to the name of the file
22
- // - autoindex:offset assumes files export "named symbols" but that each
23
- // file's symbols should be offset by the file's name
24
- //
25
- // You may also exclude certain files or directories by adding it to the
26
- // autoindex command. As an example:
27
- //
28
- // - autoindex:named, exclude: foo,bar,baz
29
- //
30
- // Inversely, if you state a file to be an "orphan" then autoindex files
31
- // below this file will not reference this autoindex file:
32
- //
33
- // - autoindex:named, orphan
34
- //
35
- // All content outside the "// #region" section in this file will be
36
- // preserved in situations where you need to do something paricularly awesome.
37
- // Keep on being awesome.
12
+ // see https://github.com/inocan-group/do-devops/docs/autoindex.md
13
+ // for more info
@@ -1,3 +1,5 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { CamelCase } from "../src/types";
2
4
  import { Expect, Equal } from "@type-challenges/utils";
3
5
 
@@ -1,5 +1,6 @@
1
- /* eslint-disable unicorn/consistent-function-scoping */
2
- import { ExplicitFunction } from "~/utility";
1
+ import { describe, it, expect } from "vitest";
2
+
3
+ import { ExplicitFunction } from "../src/utility";
3
4
  import type { Expect, Equal } from "@type-challenges/utils";
4
5
 
5
6
  describe("ExplicitFunction()", () => {
@@ -1,4 +1,6 @@
1
- import { Include, Retain } from "~/types";
1
+ import { describe, it, expect } from "vitest";
2
+
3
+ import { Include, Retain } from "../src/types";
2
4
  import { Equal, Expect } from "@type-challenges/utils";
3
5
 
4
6
  // INCLUDE
@@ -8,10 +10,7 @@ describe("Include<T, U> utility", () => {
8
10
  type Foo = Include<typeof str, string>;
9
11
  type NotFoo = Include<typeof str, number>;
10
12
 
11
- type cases = [
12
- Expect<Equal<Foo, "foo">>,
13
- Expect<Equal<NotFoo, never>>
14
- ];
13
+ type cases = [Expect<Equal<Foo, "foo">>, Expect<Equal<NotFoo, never>>];
15
14
  const c: cases = [true, true];
16
15
  expect(c).toBe(c);
17
16
  });
@@ -33,12 +32,11 @@ describe("Include<T, U> utility", () => {
33
32
  Expect<Equal<RelatedFoo, "foo">>,
34
33
  // this behavior is adjusted if you include
35
34
  // the optional `L` generic as a true value
36
- Expect<Equal<NotLiteralFoo, never>>,
35
+ Expect<Equal<NotLiteralFoo, never>>
37
36
  ];
38
37
  const c: cases = [true, true, true, true];
39
38
  expect(c).toBe(c);
40
39
  });
41
-
42
40
  });
43
41
 
44
42
  // RETAIN
@@ -52,7 +50,7 @@ describe("Retain<T, U> utility", () => {
52
50
  type cases = [
53
51
  Expect<Equal<FooBar, { foo: number; bar: number }>>,
54
52
  Expect<Equal<Baz, { baz: string }>>,
55
- Expect<Equal<FooBaz, { foo: number; baz: string }>>,
53
+ Expect<Equal<FooBaz, { foo: number; baz: string }>>
56
54
  ];
57
55
  const c: cases = [true, true, true];
58
56
  expect(c).toBe(c);
@@ -62,11 +60,8 @@ describe("Retain<T, U> utility", () => {
62
60
  type Obj = { foo: 1; bar?: number; baz: "hi" };
63
61
  type FooBar = Retain<Obj, "foo" | "bar">;
64
62
 
65
- type cases = [
66
- Expect<Equal<FooBar, { foo: 1; bar?: number }>>,
67
- ];
63
+ type cases = [Expect<Equal<FooBar, { foo: 1; bar?: number }>>];
68
64
  const c: cases = [true];
69
65
  expect(c).toBe(c);
70
66
  });
71
-
72
67
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import type { Includes } from "../src/types";
2
4
  import type { ExpectTrue, ExpectFalse } from "@type-challenges/utils";
3
5
 
@@ -1,3 +1,5 @@
1
+ import { describe, it } from "vitest";
2
+
1
3
  import type { KebabCase } from "../src/types";
2
4
  import type { Expect, Equal } from "@type-challenges/utils";
3
5
 
@@ -1,4 +1,5 @@
1
- /* eslint-disable unicorn/consistent-function-scoping */
1
+ import { describe, it, expect } from "vitest";
2
+
2
3
  import { MutationIdentity } from "../src/Mutation";
3
4
  import type { Expect, Equal, ExpectExtends } from "@type-challenges/utils";
4
5
 
@@ -1,3 +1,5 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import type { PascalCase } from "../src/types";
2
4
  import type { Expect, Equal } from "@type-challenges/utils";
3
5
 
@@ -1,3 +1,5 @@
1
+ import { describe, it } from "vitest";
2
+
1
3
  import type { Pluralize } from "../src/types";
2
4
  import type { Expect, Equal } from "@type-challenges/utils";
3
5
 
@@ -1,3 +1,5 @@
1
+ import { describe, it } from "vitest";
2
+
1
3
  import { SnakeCase } from "../src/types";
2
4
  import { Expect, Equal } from "@type-challenges/utils";
3
5
 
@@ -1,8 +1,9 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Expect, Equal } from "@type-challenges/utils";
2
4
  import { Where, WhereNot } from "../src/types/Where";
3
5
 
4
6
  describe("Where<T,U> and WhereNot<T,U> type utility", () => {
5
-
6
7
  it("readonly string array works correctly", () => {
7
8
  const arr = ["foo", "bar", "baz"] as const;
8
9
  type A = typeof arr;
@@ -11,29 +12,27 @@ describe("Where<T,U> and WhereNot<T,U> type utility", () => {
11
12
 
12
13
  type cases = [
13
14
  //
14
- Expect<Equal<B, "bar"| "baz">>,
15
+ Expect<Equal<B, "bar" | "baz">>,
15
16
  Expect<Equal<F, "foo">>
16
17
  ];
17
-
18
- const c: cases = [ true, true ];
18
+
19
+ const c: cases = [true, true];
19
20
  expect(c).toBe(c);
20
21
  });
21
22
 
22
23
  it("object with literal keys works", () => {
23
- const arr = {foo: true, bar: true, baz: true} as const;
24
+ const arr = { foo: true, bar: true, baz: true } as const;
24
25
  type A = typeof arr;
25
26
  type B = Where<A, `ba${string}`>;
26
27
  type F = WhereNot<A, `ba${string}`>;
27
28
 
28
29
  type cases = [
29
30
  //
30
- Expect<Equal<B, "bar"| "baz">>,
31
+ Expect<Equal<B, "bar" | "baz">>,
31
32
  Expect<Equal<F, "foo">>
32
33
  ];
33
-
34
- const c: cases = [ true, true ];
34
+
35
+ const c: cases = [true, true];
35
36
  expect(c).toBe(c);
36
37
  });
37
-
38
-
39
38
  });
@@ -1,5 +1,7 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Equal, Expect } from "@type-challenges/utils";
2
- import { arrayToKeyLookup } from "~/utility";
4
+ import { arrayToKeyLookup } from "../src/utility";
3
5
 
4
6
  describe("arrayToKeyLookup()", () => {
5
7
  it("simple string array is converted", () => {
@@ -8,10 +10,8 @@ describe("arrayToKeyLookup()", () => {
8
10
  expect(lookup.bar).toBe(true);
9
11
  expect(lookup.baz).toBe(true);
10
12
 
11
- type cases = [
12
- Expect<Equal<typeof lookup, Record<"foo" | "bar" | "baz", true>>>
13
- ];
13
+ type cases = [Expect<Equal<typeof lookup, Record<"foo" | "bar" | "baz", true>>>];
14
14
  const cases: cases = [true];
15
15
  expect(cases).toBe(cases);
16
16
  });
17
- });
17
+ });
@@ -1,15 +1,21 @@
1
+ import { describe, it, expect } from "vitest";
1
2
 
2
3
  import { Equal, Expect, ExpectExtends } from "@type-challenges/utils";
3
- import { ArrayConverter, arrayToObject, GeneralDictionary, UniqueDictionary, defineType, keys } from "~/utility";
4
+ import {
5
+ ArrayConverter,
6
+ arrayToObject,
7
+ GeneralDictionary,
8
+ UniqueDictionary,
9
+ defineType,
10
+ keys,
11
+ } from "../src/utility";
4
12
 
5
13
  const foo = { name: "foo", age: 123, color: "red" } as const;
6
14
  const foo2 = { name: "foo", age: 44, color: "orange" } as const;
7
15
  const bar = { name: "bar", age: 456, color: "blue" } as const;
8
16
  const baz = { name: "baz", age: 42, color: "green" } as const;
9
17
 
10
-
11
18
  describe("arrayToObject => ", () => {
12
-
13
19
  it("partial application of arrayToObject()", () => {
14
20
  const t1 = arrayToObject("name", false);
15
21
  type T1 = typeof t1;
@@ -28,7 +34,7 @@ describe("arrayToObject => ", () => {
28
34
  // The response types for each type is as expected
29
35
  Expect<ExpectExtends<GeneralDictionary<"name", any, any>, ReturnType<T1>>>,
30
36
  Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T2>>>,
31
- Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T3>>>,
37
+ Expect<ExpectExtends<UniqueDictionary<"name", any, any>, ReturnType<T3>>>
32
38
  ];
33
39
 
34
40
  const cases: cases = [true, true, true, true, true, true];
@@ -71,7 +77,7 @@ describe("arrayToObject => ", () => {
71
77
  // however when we passed in two "types" for "foo" we get a union
72
78
  Expect<Equal<typeof dict2["foo"], SomeFoo>>,
73
79
  // once we state that foo is not unique, the type expanded to an array
74
- Expect<Equal<typeof dict3["foo"], SomeFoo[]>>,
80
+ Expect<Equal<typeof dict3["foo"], SomeFoo[]>>
75
81
  ];
76
82
  const cases: cases = [true, true, true, true, true];
77
83
  expect(cases).toBe(cases);
@@ -100,12 +106,10 @@ describe("arrayToObject => ", () => {
100
106
  Expect<Equal<Slug["bob"]["slug"], "bob">>,
101
107
  // "age" and "color" are expressed as their widened types
102
108
  Expect<Equal<Id["1"]["age"], number>>,
103
- Expect<Equal<Id["1"]["color"], string>>,
109
+ Expect<Equal<Id["1"]["color"], string>>
104
110
  ];
105
111
 
106
112
  const cases: cases = [true, true, true, true, true, true];
107
113
  expect(cases).toBe(cases);
108
114
  });
109
-
110
-
111
115
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it, expect } from "vitest";
2
+
1
3
  import { Expect, Equal } from "@type-challenges/utils";
2
4
  import { Constructor } from "../src/types/Constructor";
3
5
 
@@ -1,5 +1,5 @@
1
- /* eslint-disable unicorn/consistent-function-scoping */
2
- import { createFnWithProps } from "~/index";
1
+ import { describe, it, expect } from "vitest";
2
+ import { createFnWithProps } from "../src/index";
3
3
 
4
4
  describe("createFnWithProps()", () => {
5
5
  it("simple fn and prop are combined, type is retained", () => {
@@ -1,35 +1,12 @@
1
1
  // #autoindex
2
2
 
3
- // #region autoindexed files
4
- // index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
5
- // hash-code: da242834
3
+ // #region auto-indexed files
4
+ // index last changed at: 8th Aug, 2022, 06:09 PM ( GMT-7 )
5
+ // hash-code: 683d9860
6
6
 
7
7
 
8
8
 
9
- // #endregion
9
+ // #endregion auto-indexed files
10
10
 
11
- // This file was created by running: "dd autoindex"; it assumes you have
12
- // the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
13
- //
14
- // By default it assumes that exports are named exports but this can be changed by
15
- // adding a modifier to the '// #autoindex' syntax:
16
- //
17
- // - autoindex:named same as default, exports "named symbols"
18
- // - autoindex:default assumes each file is exporting a default export and
19
- // converts the default export to the name of the file
20
- // - autoindex:offset assumes files export "named symbols" but that each
21
- // file's symbols should be offset by the file's name
22
- //
23
- // You may also exclude certain files or directories by adding it to the
24
- // autoindex command. As an example:
25
- //
26
- // - autoindex:named, exclude: foo,bar,baz
27
- //
28
- // Inversely, if you state a file to be an "orphan" then autoindex files
29
- // below this file will not reference this autoindex file:
30
- //
31
- // - autoindex:named, orphan
32
- //
33
- // All content outside the "// #region" section in this file will be
34
- // preserved in situations where you need to do something paricularly awesome.
35
- // Keep on being awesome.
11
+ // see https://github.com/inocan-group/do-devops/docs/autoindex.md
12
+ // for more info
@@ -1,7 +1,8 @@
1
- import type { Expect, Equal } from "@type-challenges/utils";
2
- import { ExpectExtends } from "~/types";
3
- import { defineType } from "~/utility";
1
+ import { describe, it, expect } from "vitest";
4
2
 
3
+ import type { Expect, Equal } from "@type-challenges/utils";
4
+ import { ExpectExtends } from "../src/types";
5
+ import { defineType } from "../src/utility";
5
6
 
6
7
  describe("inferredType() utility", () => {
7
8
  it("only specify a wide type", () => {
@@ -22,7 +23,16 @@ describe("inferredType() utility", () => {
22
23
  Expect<Equal<typeof t, { foo: string; bar: number }>>,
23
24
  // for some odd reason, when we let the default value for literal
24
25
  // we get something odd
25
- Expect<Equal<typeof t2, { foo: string; bar: number;[x: string]: string | number | boolean | symbol | void | object | {} | null | undefined }>>,
26
+ Expect<
27
+ Equal<
28
+ typeof t2,
29
+ {
30
+ foo: string;
31
+ bar: number;
32
+ [x: string]: string | number | boolean | symbol | void | object | {} | null | undefined;
33
+ }
34
+ >
35
+ >,
26
36
  // fortunately it does extend the intended type
27
37
  Expect<ExpectExtends<typeof t2, { foo: string; bar: number }>>
28
38
  ];
@@ -32,9 +42,7 @@ describe("inferredType() utility", () => {
32
42
 
33
43
  it("only specify a literal type", () => {
34
44
  const t = defineType({ foo: 1, bar: "hi" })();
35
- type cases = [
36
- Expect<Equal<typeof t, { foo: 1; bar: "hi" }>>
37
- ];
45
+ type cases = [Expect<Equal<typeof t, { foo: 1; bar: "hi" }>>];
38
46
  const cases: cases = [true];
39
47
  expect(cases).toBe(cases);
40
48
  });
@@ -42,10 +50,8 @@ describe("inferredType() utility", () => {
42
50
  it("specify both wide and literal merged type", () => {
43
51
  const t = defineType({ bar: 1 })({ foo: "" });
44
52
 
45
- type cases = [
46
- Expect<Equal<typeof t, { foo: string; bar: 1 }>>
47
- ];
53
+ type cases = [Expect<Equal<typeof t, { foo: string; bar: 1 }>>];
48
54
  const cases: cases = [true];
49
55
  expect(cases).toBe(cases);
50
56
  });
51
- });
57
+ });