type-plus 8.0.0-beta.7 → 8.0.0-beta.8

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 (216) hide show
  1. package/cjs/array/array.reverse.d.ts +1 -1
  2. package/cjs/array/array.reverse.d.ts.map +1 -1
  3. package/cjs/array/literal_array.js +1 -2
  4. package/cjs/array/literal_array.js.map +1 -1
  5. package/cjs/array/reduce_while.js +1 -2
  6. package/cjs/array/reduce_while.js.map +1 -1
  7. package/cjs/assertion/assert_type.d.ts +1 -1
  8. package/cjs/assertion/assert_type.d.ts.map +1 -1
  9. package/cjs/assertion/assert_type.js +1 -4
  10. package/cjs/assertion/assert_type.js.map +1 -1
  11. package/cjs/class/isConstructor.js +2 -3
  12. package/cjs/class/isConstructor.js.map +1 -1
  13. package/cjs/function/extract_function.d.ts.map +1 -1
  14. package/cjs/function/extract_function.js +1 -2
  15. package/cjs/function/extract_function.js.map +1 -1
  16. package/cjs/functional/Maybe.js +2 -3
  17. package/cjs/functional/Maybe.js.map +1 -1
  18. package/cjs/functional/compose.js +1 -2
  19. package/cjs/functional/compose.js.map +1 -1
  20. package/cjs/functional/context.js +1 -2
  21. package/cjs/functional/context.js.map +1 -1
  22. package/cjs/index.d.ts +1 -1
  23. package/cjs/index.d.ts.map +1 -1
  24. package/cjs/index.js.map +1 -1
  25. package/cjs/json.js +1 -1
  26. package/cjs/json.js.map +1 -1
  27. package/cjs/math/numeric_struct.d.ts.map +1 -1
  28. package/cjs/mix_types/merge.js +1 -2
  29. package/cjs/mix_types/merge.js.map +1 -1
  30. package/cjs/nodejs/isNodeError.js +1 -2
  31. package/cjs/nodejs/isNodeError.js.map +1 -1
  32. package/cjs/nominal/brand.js +1 -2
  33. package/cjs/nominal/brand.js.map +1 -1
  34. package/cjs/nominal/flavor.js +1 -2
  35. package/cjs/nominal/flavor.js.map +1 -1
  36. package/cjs/nominal/nominal_match.js +1 -2
  37. package/cjs/nominal/nominal_match.js.map +1 -1
  38. package/cjs/object/ANotB.d.ts +1 -1
  39. package/cjs/object/ANotB.d.ts.map +1 -1
  40. package/cjs/object/KeysWithDiffType.d.ts +1 -1
  41. package/cjs/object/KeysWithDiffType.d.ts.map +1 -1
  42. package/cjs/object/adjust_exact_optional_props.d.ts +7 -4
  43. package/cjs/object/adjust_exact_optional_props.d.ts.map +1 -1
  44. package/cjs/object/everyKey.js +1 -2
  45. package/cjs/object/everyKey.js.map +1 -1
  46. package/cjs/object/facade.js +1 -2
  47. package/cjs/object/facade.js.map +1 -1
  48. package/cjs/object/filterKey.js +1 -2
  49. package/cjs/object/filterKey.js.map +1 -1
  50. package/cjs/object/findKey.js +1 -2
  51. package/cjs/object/findKey.js.map +1 -1
  52. package/cjs/object/forEachKey.js +1 -2
  53. package/cjs/object/forEachKey.js.map +1 -1
  54. package/cjs/object/getField.js +1 -2
  55. package/cjs/object/getField.js.map +1 -1
  56. package/cjs/object/hasKey.js +1 -2
  57. package/cjs/object/hasKey.js.map +1 -1
  58. package/cjs/object/hasProperty.js +1 -2
  59. package/cjs/object/hasProperty.js.map +1 -1
  60. package/cjs/object/index.d.ts +6 -6
  61. package/cjs/object/index.d.ts.map +1 -1
  62. package/cjs/object/index.js.map +1 -1
  63. package/cjs/object/left_join.d.ts +1 -1
  64. package/cjs/object/left_join.d.ts.map +1 -1
  65. package/cjs/object/mapKey.js +1 -2
  66. package/cjs/object/mapKey.js.map +1 -1
  67. package/cjs/object/mapProperties.d.ts +1 -1
  68. package/cjs/object/mapProperties.d.ts.map +1 -1
  69. package/cjs/object/mapProperties.js +1 -2
  70. package/cjs/object/mapProperties.js.map +1 -1
  71. package/cjs/object/merge.d.ts +1 -1
  72. package/cjs/object/merge.d.ts.map +1 -1
  73. package/cjs/object/omit.js +1 -2
  74. package/cjs/object/omit.js.map +1 -1
  75. package/cjs/object/optional_key.d.ts +1 -1
  76. package/cjs/object/optional_key.d.ts.map +1 -1
  77. package/cjs/object/pick.js +1 -2
  78. package/cjs/object/pick.js.map +1 -1
  79. package/cjs/object/properties.d.ts +29 -4
  80. package/cjs/object/properties.d.ts.map +1 -1
  81. package/cjs/object/properties.js +1 -0
  82. package/cjs/object/properties.js.map +1 -1
  83. package/cjs/object/record.d.ts.map +1 -1
  84. package/cjs/object/record.js +1 -2
  85. package/cjs/object/record.js.map +1 -1
  86. package/cjs/object/reduceKey.js +2 -2
  87. package/cjs/object/reduceKey.js.map +1 -1
  88. package/cjs/object/replaceProperty.js +1 -2
  89. package/cjs/object/replaceProperty.js.map +1 -1
  90. package/cjs/object/someKey.js +1 -2
  91. package/cjs/object/someKey.js.map +1 -1
  92. package/cjs/object/split.d.ts +1 -1
  93. package/cjs/object/split.d.ts.map +1 -1
  94. package/cjs/object/split.js +1 -2
  95. package/cjs/object/split.js.map +1 -1
  96. package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -1
  97. package/cjs/object/typeOverrideIncompatible.js +1 -2
  98. package/cjs/object/typeOverrideIncompatible.js.map +1 -1
  99. package/cjs/predicates/CanAssign.d.ts +1 -1
  100. package/cjs/predicates/CanAssign.d.ts.map +1 -1
  101. package/cjs/predicates/CanAssign.js +1 -2
  102. package/cjs/predicates/CanAssign.js.map +1 -1
  103. package/cjs/predicates/index.d.ts +1 -1
  104. package/cjs/predicates/index.d.ts.map +1 -1
  105. package/cjs/predicates/index.js.map +1 -1
  106. package/cjs/promise/MaybePromise.js +2 -2
  107. package/cjs/promise/MaybePromise.js.map +1 -1
  108. package/cjs/promise/index.d.ts +1 -1
  109. package/cjs/promise/index.d.ts.map +1 -1
  110. package/cjs/promise/index.js +1 -1
  111. package/cjs/promise/index.js.map +1 -1
  112. package/cjs/promise/isPromise.js +2 -3
  113. package/cjs/promise/isPromise.js.map +1 -1
  114. package/cjs/promise/mapSeries.js +1 -2
  115. package/cjs/promise/mapSeries.js.map +1 -1
  116. package/cjs/string/$extract_manipulated_string.d.ts.map +1 -1
  117. package/cjs/string/_string_type.d.ts.map +1 -1
  118. package/cjs/testing/stub.d.ts +2 -2
  119. package/cjs/testing/stub.d.ts.map +1 -1
  120. package/cjs/testing/stub.js +1 -2
  121. package/cjs/testing/stub.js.map +1 -1
  122. package/cjs/tuple/drop.js +1 -2
  123. package/cjs/tuple/drop.js.map +1 -1
  124. package/cjs/type-guard/is_type.d.ts +2 -2
  125. package/cjs/type-guard/is_type.d.ts.map +1 -1
  126. package/cjs/type-guard/is_type.js +1 -2
  127. package/cjs/type-guard/is_type.js.map +1 -1
  128. package/cjs/union/union_to_intersection.js +1 -2
  129. package/cjs/union/union_to_intersection.js.map +1 -1
  130. package/cjs/utils/as.d.ts +1 -1
  131. package/cjs/utils/as.d.ts.map +1 -1
  132. package/cjs/utils/as.js +3 -4
  133. package/cjs/utils/as.js.map +1 -1
  134. package/cjs/utils/inspect.js +1 -2
  135. package/cjs/utils/inspect.js.map +1 -1
  136. package/esm/array/array.reverse.d.ts +1 -1
  137. package/esm/array/array.reverse.d.ts.map +1 -1
  138. package/esm/assertion/assert_type.d.ts +1 -1
  139. package/esm/assertion/assert_type.d.ts.map +1 -1
  140. package/esm/assertion/assert_type.js +0 -2
  141. package/esm/assertion/assert_type.js.map +1 -1
  142. package/esm/function/extract_function.d.ts.map +1 -1
  143. package/esm/index.d.ts +1 -1
  144. package/esm/index.d.ts.map +1 -1
  145. package/esm/index.js.map +1 -1
  146. package/esm/json.js +1 -1
  147. package/esm/json.js.map +1 -1
  148. package/esm/math/numeric_struct.d.ts.map +1 -1
  149. package/esm/object/ANotB.d.ts +1 -1
  150. package/esm/object/ANotB.d.ts.map +1 -1
  151. package/esm/object/KeysWithDiffType.d.ts +1 -1
  152. package/esm/object/KeysWithDiffType.d.ts.map +1 -1
  153. package/esm/object/adjust_exact_optional_props.d.ts +7 -4
  154. package/esm/object/adjust_exact_optional_props.d.ts.map +1 -1
  155. package/esm/object/index.d.ts +6 -6
  156. package/esm/object/index.d.ts.map +1 -1
  157. package/esm/object/index.js.map +1 -1
  158. package/esm/object/left_join.d.ts +1 -1
  159. package/esm/object/left_join.d.ts.map +1 -1
  160. package/esm/object/mapProperties.d.ts +1 -1
  161. package/esm/object/mapProperties.d.ts.map +1 -1
  162. package/esm/object/mapProperties.js.map +1 -1
  163. package/esm/object/merge.d.ts +1 -1
  164. package/esm/object/merge.d.ts.map +1 -1
  165. package/esm/object/optional_key.d.ts +1 -1
  166. package/esm/object/optional_key.d.ts.map +1 -1
  167. package/esm/object/properties.d.ts +29 -4
  168. package/esm/object/properties.d.ts.map +1 -1
  169. package/esm/object/properties.js +1 -0
  170. package/esm/object/properties.js.map +1 -1
  171. package/esm/object/record.d.ts.map +1 -1
  172. package/esm/object/split.d.ts +1 -1
  173. package/esm/object/split.d.ts.map +1 -1
  174. package/esm/object/typeOverrideIncompatible.d.ts.map +1 -1
  175. package/esm/predicates/CanAssign.d.ts +1 -1
  176. package/esm/predicates/CanAssign.d.ts.map +1 -1
  177. package/esm/predicates/index.d.ts +1 -1
  178. package/esm/predicates/index.d.ts.map +1 -1
  179. package/esm/predicates/index.js.map +1 -1
  180. package/esm/promise/index.d.ts +1 -1
  181. package/esm/promise/index.d.ts.map +1 -1
  182. package/esm/promise/index.js +1 -1
  183. package/esm/promise/index.js.map +1 -1
  184. package/esm/promise/isPromise.js +1 -1
  185. package/esm/promise/isPromise.js.map +1 -1
  186. package/esm/string/$extract_manipulated_string.d.ts.map +1 -1
  187. package/esm/string/_string_type.d.ts.map +1 -1
  188. package/esm/testing/stub.d.ts +2 -2
  189. package/esm/testing/stub.d.ts.map +1 -1
  190. package/esm/type-guard/is_type.d.ts +2 -2
  191. package/esm/type-guard/is_type.d.ts.map +1 -1
  192. package/esm/utils/as.d.ts +1 -1
  193. package/esm/utils/as.d.ts.map +1 -1
  194. package/package.json +16 -20
  195. package/src/array/array.reverse.ts +2 -5
  196. package/src/assertion/assert_type.ts +0 -2
  197. package/src/index.ts +1 -1
  198. package/src/json.ts +1 -1
  199. package/src/math/numeric_struct.ts +6 -6
  200. package/src/object/ANotB.ts +1 -1
  201. package/src/object/KeysWithDiffType.ts +1 -1
  202. package/src/object/adjust_exact_optional_props.ts +11 -2
  203. package/src/object/index.ts +6 -6
  204. package/src/object/left_join.ts +1 -1
  205. package/src/object/mapProperties.ts +1 -1
  206. package/src/object/merge.ts +1 -1
  207. package/src/object/optional_key.ts +1 -1
  208. package/src/object/properties.ts +35 -2
  209. package/src/object/record.ts +1 -1
  210. package/src/object/split.ts +1 -1
  211. package/src/predicates/CanAssign.ts +1 -1
  212. package/src/predicates/index.ts +1 -1
  213. package/src/promise/index.ts +1 -1
  214. package/src/promise/isPromise.ts +1 -1
  215. package/src/string/$extract_manipulated_string.ts +32 -28
  216. package/src/string/_string_type.ts +9 -8
@@ -1 +1 @@
1
- {"version":3,"file":"is_type.d.ts","sourceRoot":"","sources":["../../src/type-guard/is_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,CAAA;AACnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,IAAI,CAAC,CAAA;yBAAvE,MAAM;;;;;;AAetB;;;GAGG;AACH,iBAAS,OAAO,CAAC,EAAE,SAAS,KAAK,KAAK,OAAO,CAAA;AAC7C;;;GAGG;AACH,iBAAS,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,IAAI,KAAK,CAAA"}
1
+ {"version":3,"file":"is_type.d.ts","sourceRoot":"","sources":["../../src/type-guard/is_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,CAAA;AACnD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,IAAI,CAAC,CAAA;yBAAvE,MAAM;YAQV,CAAC,SAAS,IAAI,YAAY,CAAC;YAK3B,CAAC,SAAS,KAAK,YAAY,CAAC;;gBAyBxB,EAAE,SAAS,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;;AAvB9C;;;GAGG;AACH,iBAAS,OAAO,CAAC,EAAE,SAAS,KAAK,KAAK,OAAO,CAAA;AAC7C;;;GAGG;AACH,iBAAS,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,IAAI,KAAK,CAAA"}
package/esm/utils/as.d.ts CHANGED
@@ -5,6 +5,6 @@ export declare function asAny(subject: unknown): any;
5
5
  */
6
6
  export declare function amend<S>(subject: S): {
7
7
  union<T>(): T & S;
8
- intersect<T_1>(): S | T_1;
8
+ intersect<T>(): T | S;
9
9
  };
10
10
  //# sourceMappingURL=as.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../src/utils/as.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAEzC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAE3C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;gBAErB,CAAC,GAAG,CAAC;;EAOlB"}
1
+ {"version":3,"file":"as.d.ts","sourceRoot":"","sources":["../../src/utils/as.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAEzC;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAE3C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;UAE3B,CAAC,KAAK,CAAC,GAAG,CAAC;cAGP,CAAC,KAAK,CAAC,GAAG,CAAC;EAItB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-plus",
3
- "version": "8.0.0-beta.7",
3
+ "version": "8.0.0-beta.8",
4
4
  "description": "Provides additional types for TypeScript.",
5
5
  "keywords": [
6
6
  "assert",
@@ -55,46 +55,42 @@
55
55
  "unpartial": "^1.0.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@jest/globals": "^29.5.0",
59
- "@repobuddy/jest": "^4.0.0",
60
58
  "@repobuddy/typescript": "^2.0.0",
61
59
  "@size-limit/esbuild-why": "^11.1.5",
62
60
  "@size-limit/preset-small-lib": "^11.1.5",
63
61
  "@types/node": "^18.11.11",
62
+ "@vitest/coverage-v8": "^4.0.15",
64
63
  "assertron": "^11.0.2",
65
64
  "cross-env": "^7.0.3",
66
- "depcheck": "^1.4.3",
67
- "jest": "^29.7.0",
68
- "jest-watch-suspend": "^1.1.2",
69
- "jest-watch-toggle-config-2": "^2.1.0",
70
- "jest-watch-typeahead": "^2.2.2",
71
- "npm-run-all2": "^7.0.0",
65
+ "npm-run-all2": "^8.0.0",
72
66
  "rimraf": "^6.0.0",
73
67
  "size-limit": "^11.1.5",
74
68
  "ts-5.4": "npm:typescript@~5.4.0",
75
69
  "ts-5.5": "npm:typescript@~5.5.0",
76
- "ts-jest": "^29.1.2",
77
- "typescript": "^5.6.2"
70
+ "typescript": "~5.6.0",
71
+ "vitest": "^4.0.15"
72
+ },
73
+ "peerDependencies": {
74
+ "typescript": ">= 5.6.0"
78
75
  },
79
76
  "scripts": {
80
77
  "build": "run-p build:*",
81
78
  "build:cjs": "tsc -p tsconfig.cjs.json",
82
79
  "build:esm": "tsc -p tsconfig.esm.json",
83
- "build:doc": "typedoc",
84
80
  "clean": "rimraf cjs coverage esm lib libm tslib --glob *.tsbuildinfo",
85
- "coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --coverage",
86
- "depcheck": "depcheck",
81
+ "coverage": "vitest run --coverage",
82
+ "knip": "knip",
87
83
  "nuke": "run-p clean nuke:local",
88
84
  "nuke:local": "rimraf node_modules",
89
85
  "size": "size-limit",
90
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest",
86
+ "test": "vitest run",
91
87
  "test:type": "run-p test:type:*",
92
- "test:type:latest": "./node_modules/typescript/bin/tsc --noEmit",
93
88
  "test:type:54": "./node_modules/ts-5.4/bin/tsc -p tsconfig.ts54.json --noEmit",
94
89
  "test:type:55": "./node_modules/ts-5.5/bin/tsc -p tsconfig.ts55.json --noEmit",
95
- "test:watch": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch",
96
- "verify": "npm-run-all clean -p build depcheck lint coverage -p size",
97
- "w": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch",
98
- "watch": "cross-env NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 jest --watch"
90
+ "test:type:latest": "./node_modules/typescript/bin/tsc --noEmit",
91
+ "test:watch": "vitest watch",
92
+ "verify": "npm-run-all clean -p build knip lint coverage -p size",
93
+ "w": "vitest watch",
94
+ "watch": "vitest watch"
99
95
  }
100
96
  }
@@ -13,11 +13,8 @@ import type { IsReadonly } from './array_plus.is_readonly.js'
13
13
  * @param T The array type to reverse.
14
14
  * @returns The reversed array type.
15
15
  */
16
- export type Reverse<A extends readonly unknown[]> = Reverse._<A> extends infer R
17
- ? IsReadonly<A> extends true
18
- ? Readonly<R>
19
- : R
20
- : never
16
+ export type Reverse<A extends readonly unknown[]> =
17
+ Reverse._<A> extends infer R ? (IsReadonly<A> extends true ? Readonly<R> : R) : never
21
18
 
22
19
  export namespace Reverse {
23
20
  export type _<A extends readonly unknown[]> = A extends readonly [infer First, ...infer Rest]
@@ -58,7 +58,6 @@ assertType.isTrue = (subject: true): asserts subject is true => {
58
58
  if (subject !== true) throw TypeError('subject is not true')
59
59
  }
60
60
  assertType.noTrue = <S>(subject: Exclude<S, true>): void => {
61
- // @ts-ignore
62
61
  if (subject === true) throw TypeError('subject is true')
63
62
  }
64
63
 
@@ -66,7 +65,6 @@ assertType.isFalse = (subject: false): asserts subject is false => {
66
65
  if (subject !== false) throw TypeError('subject is not false')
67
66
  }
68
67
  assertType.noFalse = <S>(subject: Exclude<S, false>): void => {
69
- // @ts-ignore
70
68
  if (subject === false) throw TypeError('subject is false')
71
69
  }
72
70
 
package/src/index.ts CHANGED
@@ -114,8 +114,8 @@ export * from './testing/stub.js'
114
114
  export * from './testing/test_type.js'
115
115
  export type { CommonKeys, CommonPropKeys } from './tuple/common_prop_keys.js'
116
116
  export * from './tuple/create_tuple.js'
117
- export { drop } from './tuple/drop.js'
118
117
  export type { DropFirst, DropLast, DropMatch, DropNull, DropNullable, DropUndefined } from './tuple/drop.js'
118
+ export { drop } from './tuple/drop.js'
119
119
  export type * from './tuple/is_not_tuple.js'
120
120
  export type * from './tuple/is_tuple.js'
121
121
  export type { Tail } from './tuple/tail.js'
package/src/json.ts CHANGED
@@ -12,6 +12,6 @@ function get<T extends JSONTypes>(obj: JSONTypes, ...props: Array<string | numbe
12
12
  if (props.length === 0) return obj as T
13
13
  if (typeof obj !== 'object' || obj === null) return undefined
14
14
  const p = props.shift()!
15
- // @ts-ignore
15
+ // @ts-expect-error
16
16
  return get(obj[p], ...props) as T
17
17
  }
@@ -96,12 +96,12 @@ export namespace NumericStruct {
96
96
  *
97
97
  * It includes the normalization of the `NumericStruct`.
98
98
  */
99
- export type ToNumeric<M extends NumericStruct> = DigitsStruct.ToString<M[DIGITS_STRUCT]> extends infer S extends
100
- string
101
- ? M[TYPE] extends 'bigint'
102
- ? StringToBigint<S, StringToNumber<S, `The value '${S}' cannot be represented as bigint or number`>>
103
- : StringToNumber<S, StringToBigint<S, `The value '${S}' cannot be represented as bigint or number`>>
104
- : never
99
+ export type ToNumeric<M extends NumericStruct> =
100
+ DigitsStruct.ToString<M[DIGITS_STRUCT]> extends infer S extends string
101
+ ? M[TYPE] extends 'bigint'
102
+ ? StringToBigint<S, StringToNumber<S, `The value '${S}' cannot be represented as bigint or number`>>
103
+ : StringToNumber<S, StringToBigint<S, `The value '${S}' cannot be represented as bigint or number`>>
104
+ : never
105
105
 
106
106
  export type Add<A extends NumericStruct, B extends NumericStruct> = [
107
107
  A[TYPE],
@@ -1,7 +1,7 @@
1
1
  import type { IsEqual } from '../equal/is_equal.js'
2
+ import type { AnyRecord } from './any_record.js'
2
3
  import type { IsDisjoint } from './IsDisjoint.js'
3
4
  import type { KeysWithDiffType } from './KeysWithDiffType.js'
4
- import type { AnyRecord } from './any_record.js'
5
5
 
6
6
  export type ANotB<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
7
7
  ? never
@@ -1,6 +1,6 @@
1
+ import type { AnyRecord } from './any_record.js'
1
2
  import type { IsDisjoint } from './IsDisjoint.js'
2
3
  import type { ValueOf } from './ValueOf.js'
3
- import type { AnyRecord } from './any_record.js'
4
4
 
5
5
  export type KeysWithDiffType<A extends AnyRecord, B extends AnyRecord> = IsDisjoint<A, B> extends true
6
6
  ? never
@@ -1,6 +1,6 @@
1
- import type { RequiredKeys } from './RequiredKeys.js'
2
1
  import type { AnyRecord } from './any_record.js'
3
2
  import type { OptionalKeys } from './optional_key.js'
3
+ import type { RequiredKeys } from './RequiredKeys.js'
4
4
 
5
5
  /**
6
6
  * ⚗️ *transform*
@@ -10,5 +10,14 @@ import type { OptionalKeys } from './optional_key.js'
10
10
  * It adds `undefined` to optional properties.
11
11
  */
12
12
  export type AdjustExactOptionalProps<T extends AnyRecord> = T extends object
13
- ? { [K in OptionalKeys<T>]?: T[K] | undefined } & { [K in RequiredKeys<T>]: T[K] }
13
+ ? [{ [K in OptionalKeys<T>]?: T[K] | undefined }, { [K in RequiredKeys<T>]: T[K] }] extends [
14
+ infer O extends AnyRecord,
15
+ infer R extends AnyRecord,
16
+ ]
17
+ ? keyof O extends never
18
+ ? R
19
+ : keyof R extends never
20
+ ? O
21
+ : O & R
22
+ : never
14
23
  : never
@@ -1,8 +1,8 @@
1
- export type * from './adjust_exact_optional_props.js'
2
1
  export type { ANotB, BNotA } from './ANotB.js'
2
+ export type * from './adjust_exact_optional_props.js'
3
3
  export type { AnyRecord } from './any_record.js'
4
- export * from './everyKey.js'
5
4
  export type { ExcludePropType } from './ExcludePropType.js'
5
+ export * from './everyKey.js'
6
6
  export * from './facade.js'
7
7
  export * from './filterKey.js'
8
8
  export * from './findKey.js'
@@ -25,15 +25,15 @@ export type * from './optional_key.js'
25
25
  export type { Partial, PartialExcept, PartialOmit, PartialPick } from './Partial.js'
26
26
  export * from './pick.js'
27
27
  export type { Properties } from './properties.js'
28
- export * from './record.js'
29
- export type { RecursivePartial } from './recursive_partial.js'
30
28
  export type { RecursiveIntersect } from './RecursiveIntersect.js'
31
29
  export type { RecursiveRequired } from './RecursiveRequired.js'
30
+ export type { RequiredKeys } from './RequiredKeys.js'
31
+ export * from './record.js'
32
+ export type { RecursivePartial } from './recursive_partial.js'
32
33
  export * from './reduceKey.js'
33
34
  export * from './replaceProperty.js'
34
- export type { RequiredKeys } from './RequiredKeys.js'
35
+ export type { SpreadRecord } from './SpreadRecord.js'
35
36
  export * from './someKey.js'
36
37
  export * from './split.js'
37
- export type { SpreadRecord } from './SpreadRecord.js'
38
38
  export * from './typeOverrideIncompatible.js'
39
39
  export type { ValueOf } from './ValueOf.js'
@@ -1,6 +1,6 @@
1
1
  import type { IsEqual } from '../equal/is_equal.js'
2
- import type { IsDisjoint } from './IsDisjoint.js'
3
2
  import type { AnyRecord } from './any_record.js'
3
+ import type { IsDisjoint } from './IsDisjoint.js'
4
4
  import type { Properties } from './properties.js'
5
5
 
6
6
  export type LeftJoin<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
@@ -1,6 +1,6 @@
1
- import type { ValueOf } from './ValueOf.js'
2
1
  import type { AnyRecord } from './any_record.js'
3
2
  import { reduceByKey } from './reduceKey.js'
3
+ import type { ValueOf } from './ValueOf.js'
4
4
 
5
5
  /**
6
6
  * An Object-specific version of `map`.
@@ -5,9 +5,9 @@ import type { Or } from '../logical/logical.js'
5
5
  import type { IsNever } from '../never/is_never.js'
6
6
  import type { IsNotNever } from '../never/is_not_never.js'
7
7
  import type { IsLiteral } from '../predicates/literal.js'
8
+ import type { AnyRecord } from './any_record.js'
8
9
  import type { IsDisjoint } from './IsDisjoint.js'
9
10
  import type { KeyTypes } from './KeyTypes.js'
10
- import type { AnyRecord } from './any_record.js'
11
11
  import type { OptionalKeys } from './optional_key.js'
12
12
 
13
13
  /**
@@ -1,5 +1,5 @@
1
- import type { KeyTypes } from './KeyTypes.js'
2
1
  import type { AnyRecord } from './any_record.js'
2
+ import type { KeyTypes } from './KeyTypes.js'
3
3
 
4
4
  /**
5
5
  * Validate if the key `K` in `T` is optional.
@@ -1,4 +1,37 @@
1
+ import type { IsAny } from '../any/is_any.js'
2
+ import type { IsUnknown } from '../unknown/is_unknown.js'
3
+
1
4
  /**
2
- * Gets the properties of an object type.
5
+ * Extracts the property map of a type: an object type with the same keys and
6
+ * value types as `T`, preserving optional and readonly modifiers.
7
+ *
8
+ * - For object types: returns `{ [k in keyof T]: T[k] }`.
9
+ * - For `any` and `unknown`: returns the input type unchanged.
10
+ * - For function types (e.g. `() => void`): returns `{}` because call signatures
11
+ * are not indexable; for `Function`, returns the interface of methods.
12
+ * - For intersections: merges properties from all branches.
13
+ *
14
+ * @typeParam T - The type whose properties to extract.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * type T = { a: number; b?: string }
19
+ * type R = Properties<T> // { a: number; b?: string }
20
+ *
21
+ * type Merged = Properties<{ a: 1 } & { b: 2 }> // { a: 1; b: 2 }
22
+ * ```
3
23
  */
4
- export type Properties<T> = { [k in keyof T]: T[k] } // & {}
24
+ export type Properties<T> = IsAny<
25
+ T,
26
+ {
27
+ $then: T
28
+ $else: IsUnknown<
29
+ T,
30
+ {
31
+ $then: T
32
+ $else: { [k in keyof T]: T[k] } // & {}
33
+ }
34
+ >
35
+ }
36
+ >
37
+ // [unknown] extends [T] ? unknown : { [k in keyof T]: T[k] } // & {}
@@ -1,6 +1,6 @@
1
1
  import type { Widen } from '../utils/index.js'
2
- import type { KeyTypes } from './KeyTypes.js'
3
2
  import type { AnyRecord } from './any_record.js'
3
+ import type { KeyTypes } from './KeyTypes.js'
4
4
 
5
5
  /**
6
6
  * Creates a `Record<Key, Value>` or your custom record.
@@ -1,7 +1,7 @@
1
- import type { Partial } from './Partial.js'
2
1
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
3
2
  import type { AnyRecord } from './any_record.js'
4
3
  import type { Omit } from './omit.js'
4
+ import type { Partial } from './Partial.js'
5
5
  import { reduceByKey } from './reduceKey.js'
6
6
 
7
7
  type Splitter<T extends AnyRecord> = Partial<{ [k in keyof T]: T[k] | undefined }>
@@ -1,5 +1,5 @@
1
- import type { NotExtendable } from './Extends.js'
2
1
  import type { Assignable } from './assignable.js'
2
+ import type { NotExtendable } from './Extends.js'
3
3
 
4
4
  /**
5
5
  * Can `A` assign to `B`
@@ -1,6 +1,6 @@
1
+ export type { And, Not, Or, Xor } from '../logical/logical.js'
1
2
  export * from './CanAssign.js'
2
3
  export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js'
3
4
  export type { If } from './If.js'
4
5
  export type { IsEmptyObject } from './IsEmptyObject.js'
5
6
  export type { IsLiteral } from './literal.js'
6
- export type { And, Not, Or, Xor } from '../logical/logical.js'
@@ -1,5 +1,5 @@
1
1
  export * from './isPromise.js'
2
- export * from './mapSeries.js'
3
2
  export * from './MaybePromise.js'
3
+ export * from './mapSeries.js'
4
4
  export type { AwaitedProp, PromiseValue } from './PromiseValue.js'
5
5
  export type { PromiseValueMerge } from './PromiseValueMerge.js'
@@ -1,4 +1,4 @@
1
1
  export function isPromise<R = any>(subject: unknown): subject is Promise<R> {
2
- // @ts-ignore
2
+ // @ts-expect-error
3
3
  return !!subject && typeof subject['then'] === 'function'
4
4
  }
@@ -19,32 +19,36 @@ export type $ExtractManipulatedString<T extends string> = [T, unknown] extends [
19
19
  >
20
20
 
21
21
  export namespace $ExtractManipulatedString {
22
- export type _UpperOrElse<N, Else> = N extends Uppercase<infer Y>
23
- ? string extends Y
24
- ? Uppercase<any> extends N
25
- ? Y
26
- : N
27
- : $ExtractManipulatedString<Y>
28
- : Else
29
- export type _LowerOrElse<N, Else> = N extends Lowercase<infer Y>
30
- ? string extends Y
31
- ? Lowercase<any> extends N
32
- ? Y
33
- : N
34
- : $ExtractManipulatedString<Y>
35
- : Else
36
- export type _CapOrElse<N, Else> = N extends Capitalize<infer Y>
37
- ? string extends Y
38
- ? Capitalize<any> extends N
39
- ? Y
40
- : N
41
- : $ExtractManipulatedString<Y>
42
- : Else
43
- export type _UncapOrElse<N, Else> = N extends Uncapitalize<infer Y>
44
- ? string extends Y
45
- ? Uncapitalize<any> extends N
46
- ? Y
47
- : N
48
- : $ExtractManipulatedString<Y>
49
- : Else
22
+ export type _UpperOrElse<N, Else> =
23
+ N extends Uppercase<infer Y>
24
+ ? string extends Y
25
+ ? Uppercase<any> extends N
26
+ ? Y
27
+ : N
28
+ : $ExtractManipulatedString<Y>
29
+ : Else
30
+ export type _LowerOrElse<N, Else> =
31
+ N extends Lowercase<infer Y>
32
+ ? string extends Y
33
+ ? Lowercase<any> extends N
34
+ ? Y
35
+ : N
36
+ : $ExtractManipulatedString<Y>
37
+ : Else
38
+ export type _CapOrElse<N, Else> =
39
+ N extends Capitalize<infer Y>
40
+ ? string extends Y
41
+ ? Capitalize<any> extends N
42
+ ? Y
43
+ : N
44
+ : $ExtractManipulatedString<Y>
45
+ : Else
46
+ export type _UncapOrElse<N, Else> =
47
+ N extends Uncapitalize<infer Y>
48
+ ? string extends Y
49
+ ? Uncapitalize<any> extends N
50
+ ? Y
51
+ : N
52
+ : $ExtractManipulatedString<Y>
53
+ : Else
50
54
  }
@@ -1,11 +1,12 @@
1
1
  import type { $ExtractManipulatedString } from './$extract_manipulated_string.js'
2
2
 
3
- export type _StringType<T extends string> = $ExtractManipulatedString<T> extends infer K
4
- ? K extends string & infer U
5
- ? [K, U] extends [U, K]
6
- ? {} extends { [P in `${K}`]: unknown }
7
- ? 'templateLiteral'
8
- : 'stringLiteral'
9
- : 'string'
3
+ export type _StringType<T extends string> =
4
+ $ExtractManipulatedString<T> extends infer K
5
+ ? K extends string & infer U
6
+ ? [K, U] extends [U, K]
7
+ ? {} extends { [P in `${K}`]: unknown }
8
+ ? 'templateLiteral'
9
+ : 'stringLiteral'
10
+ : 'string'
11
+ : never
10
12
  : never
11
- : never