type-plus 6.8.1 → 7.0.1

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 (531) hide show
  1. package/README.md +1054 -355
  2. package/cjs/array/{array.d.ts → array.at.d.ts} +4 -14
  3. package/cjs/array/array.at.d.ts.map +1 -0
  4. package/cjs/array/{pad_left.js → array.at.js} +1 -1
  5. package/cjs/array/array.at.js.map +1 -0
  6. package/cjs/array/array.concat.d.ts +13 -0
  7. package/cjs/array/array.concat.d.ts.map +1 -0
  8. package/cjs/array/array.concat.js +3 -0
  9. package/cjs/array/array.concat.js.map +1 -0
  10. package/cjs/array/array.entries.d.ts +17 -0
  11. package/cjs/array/array.entries.d.ts.map +1 -0
  12. package/cjs/array/array.entries.js +3 -0
  13. package/cjs/array/array.entries.js.map +1 -0
  14. package/cjs/array/array.find.d.ts +21 -0
  15. package/cjs/array/array.find.d.ts.map +1 -0
  16. package/cjs/array/{find_first.js → array.find.js} +1 -1
  17. package/cjs/array/array.find.js.map +1 -0
  18. package/cjs/array/array.find_last.d.ts +17 -0
  19. package/cjs/array/array.find_last.d.ts.map +1 -0
  20. package/cjs/array/array.find_last.js +3 -0
  21. package/cjs/array/array.find_last.js.map +1 -0
  22. package/cjs/array/array.reverse.d.ts +2 -0
  23. package/cjs/array/array.reverse.d.ts.map +1 -0
  24. package/cjs/array/array.reverse.js +3 -0
  25. package/cjs/array/array.reverse.js.map +1 -0
  26. package/cjs/array/array.some.d.ts +29 -0
  27. package/cjs/array/array.some.d.ts.map +1 -0
  28. package/cjs/array/array.some.js +3 -0
  29. package/cjs/array/array.some.js.map +1 -0
  30. package/cjs/array/array_index.d.ts +8 -8
  31. package/cjs/array/array_index.d.ts.map +1 -1
  32. package/cjs/array/array_plus.d.ts +9 -1
  33. package/cjs/array/array_plus.d.ts.map +1 -1
  34. package/cjs/array/array_plus.split_at.d.ts +35 -0
  35. package/cjs/array/array_plus.split_at.d.ts.map +1 -0
  36. package/cjs/array/array_plus.split_at.js +3 -0
  37. package/cjs/array/array_plus.split_at.js.map +1 -0
  38. package/cjs/array/drop.d.ts +2 -2
  39. package/cjs/array/drop.d.ts.map +1 -1
  40. package/cjs/array/index.d.ts +4 -5
  41. package/cjs/array/index.d.ts.map +1 -1
  42. package/cjs/array/index.js +4 -5
  43. package/cjs/array/index.js.map +1 -1
  44. package/cjs/array/pad_start.d.ts +32 -0
  45. package/cjs/array/pad_start.d.ts.map +1 -0
  46. package/cjs/array/{find_last.js → pad_start.js} +1 -1
  47. package/cjs/array/pad_start.js.map +1 -0
  48. package/cjs/assertion/assert_type.d.ts +3 -0
  49. package/cjs/assertion/assert_type.d.ts.map +1 -1
  50. package/cjs/assertion/assert_type.js +3 -0
  51. package/cjs/assertion/assert_type.js.map +1 -1
  52. package/cjs/bigint/cast.d.ts +10 -0
  53. package/cjs/bigint/cast.d.ts.map +1 -0
  54. package/cjs/{array/some.js → bigint/cast.js} +1 -1
  55. package/cjs/bigint/cast.js.map +1 -0
  56. package/cjs/equal/equal.d.ts +51 -3
  57. package/cjs/equal/equal.d.ts.map +1 -1
  58. package/cjs/functional/Maybe.d.ts +2 -2
  59. package/cjs/functional/Maybe.d.ts.map +1 -1
  60. package/cjs/index.d.ts +16 -7
  61. package/cjs/index.d.ts.map +1 -1
  62. package/cjs/index.js +6 -1
  63. package/cjs/index.js.map +1 -1
  64. package/cjs/math/abs.d.ts +6 -0
  65. package/cjs/math/abs.d.ts.map +1 -0
  66. package/cjs/math/{Add.js → abs.js} +1 -1
  67. package/cjs/math/abs.js.map +1 -0
  68. package/cjs/math/add.d.ts +7 -0
  69. package/cjs/math/add.d.ts.map +1 -0
  70. package/cjs/math/{Max.js → add.js} +1 -1
  71. package/cjs/math/add.js.map +1 -0
  72. package/cjs/math/greater_than.d.ts +4 -0
  73. package/cjs/math/greater_than.d.ts.map +1 -0
  74. package/cjs/math/greater_than.js +3 -0
  75. package/cjs/math/greater_than.js.map +1 -0
  76. package/cjs/math/index.d.ts +6 -6
  77. package/cjs/math/index.d.ts.map +1 -1
  78. package/cjs/math/math_plus.d.ts +5 -0
  79. package/cjs/math/math_plus.d.ts.map +1 -0
  80. package/cjs/math/math_plus.js +3 -0
  81. package/cjs/math/math_plus.js.map +1 -0
  82. package/cjs/math/math_plus.to_negative.d.ts +13 -0
  83. package/cjs/math/math_plus.to_negative.d.ts.map +1 -0
  84. package/cjs/math/math_plus.to_negative.js +3 -0
  85. package/cjs/math/math_plus.to_negative.js.map +1 -0
  86. package/cjs/math/max.d.ts +4 -0
  87. package/cjs/math/max.d.ts.map +1 -0
  88. package/cjs/math/{Abs.js → max.js} +1 -1
  89. package/cjs/math/max.js.map +1 -0
  90. package/cjs/math/multiply.d.ts +6 -0
  91. package/cjs/math/multiply.d.ts.map +1 -0
  92. package/cjs/{array/array.js → math/multiply.js} +1 -1
  93. package/cjs/math/multiply.js.map +1 -0
  94. package/cjs/math/numeric_struct.d.ts +1480 -0
  95. package/cjs/math/numeric_struct.d.ts.map +1 -0
  96. package/cjs/math/numeric_struct.js +3 -0
  97. package/cjs/math/numeric_struct.js.map +1 -0
  98. package/cjs/math/subtract.d.ts +7 -0
  99. package/cjs/math/subtract.d.ts.map +1 -0
  100. package/cjs/math/subtract.js +3 -0
  101. package/cjs/math/subtract.js.map +1 -0
  102. package/cjs/nominal/brand.js +2 -2
  103. package/cjs/nominal/brand.js.map +1 -1
  104. package/cjs/nominal/flavor.js +2 -2
  105. package/cjs/nominal/flavor.js.map +1 -1
  106. package/cjs/number/cast.d.ts +10 -0
  107. package/cjs/number/cast.d.ts.map +1 -0
  108. package/cjs/number/cast.js +3 -0
  109. package/cjs/number/cast.js.map +1 -0
  110. package/cjs/number/number_array.d.ts +0 -2
  111. package/cjs/number/number_array.d.ts.map +1 -1
  112. package/cjs/number/number_array.js +14 -1
  113. package/cjs/number/number_array.js.map +1 -1
  114. package/cjs/number/number_plus.d.ts +4 -5
  115. package/cjs/number/number_plus.d.ts.map +1 -1
  116. package/cjs/number/strict_number_type.d.ts +12 -0
  117. package/cjs/number/strict_number_type.d.ts.map +1 -1
  118. package/cjs/numeric/cast.d.ts +27 -0
  119. package/cjs/numeric/cast.d.ts.map +1 -0
  120. package/cjs/numeric/cast.js +3 -0
  121. package/cjs/numeric/cast.js.map +1 -0
  122. package/{esm/number → cjs/numeric}/integer.d.ts +2 -0
  123. package/cjs/numeric/integer.d.ts.map +1 -0
  124. package/cjs/{number → numeric}/integer.js.map +1 -1
  125. package/cjs/numeric/negative.d.ts.map +1 -0
  126. package/cjs/{number → numeric}/negative.js.map +1 -1
  127. package/cjs/numeric/numeric_plus.d.ts +5 -0
  128. package/cjs/numeric/numeric_plus.d.ts.map +1 -0
  129. package/cjs/numeric/numeric_plus.js +3 -0
  130. package/cjs/numeric/numeric_plus.js.map +1 -0
  131. package/cjs/numeric/numeric_type.d.ts.map +1 -0
  132. package/cjs/{number → numeric}/numeric_type.js.map +1 -1
  133. package/cjs/{number → numeric}/positive.d.ts +2 -2
  134. package/cjs/numeric/positive.d.ts.map +1 -0
  135. package/cjs/{number → numeric}/positive.js.map +1 -1
  136. package/cjs/object/ANotB.d.ts +3 -3
  137. package/cjs/object/ANotB.d.ts.map +1 -1
  138. package/cjs/object/Partial.d.ts +6 -0
  139. package/cjs/object/Partial.d.ts.map +1 -1
  140. package/cjs/object/Required.d.ts +4 -0
  141. package/cjs/object/Required.d.ts.map +1 -1
  142. package/cjs/object/index.d.ts +1 -1
  143. package/cjs/object/index.d.ts.map +1 -1
  144. package/cjs/object/object_type.d.ts +1 -1
  145. package/cjs/object/split.d.ts +3 -1
  146. package/cjs/object/split.d.ts.map +1 -1
  147. package/cjs/object/split.js.map +1 -1
  148. package/cjs/predicates/CanAssign.d.ts +35 -0
  149. package/cjs/predicates/CanAssign.d.ts.map +1 -1
  150. package/cjs/predicates/CanAssign.js.map +1 -1
  151. package/cjs/predicates/Extends.d.ts +2 -2
  152. package/cjs/predicates/Extends.d.ts.map +1 -1
  153. package/cjs/predicates/index.d.ts +0 -1
  154. package/cjs/predicates/index.d.ts.map +1 -1
  155. package/cjs/predicates/index.js +0 -1
  156. package/cjs/predicates/index.js.map +1 -1
  157. package/cjs/testing/test_type.d.ts +125 -50
  158. package/cjs/testing/test_type.d.ts.map +1 -1
  159. package/cjs/testing/test_type.js +4 -141
  160. package/cjs/testing/test_type.js.map +1 -1
  161. package/cjs/tuple/create_tuple.d.ts +28 -0
  162. package/cjs/tuple/create_tuple.d.ts.map +1 -0
  163. package/cjs/{array → tuple}/create_tuple.js.map +1 -1
  164. package/cjs/tuple/tuple_plus.d.ts +2 -0
  165. package/cjs/tuple/tuple_plus.d.ts.map +1 -0
  166. package/cjs/tuple/tuple_plus.js +18 -0
  167. package/cjs/tuple/tuple_plus.js.map +1 -0
  168. package/cjs/tuple/tuple_plus.pad_start.d.ts +22 -0
  169. package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  170. package/cjs/tuple/tuple_plus.pad_start.js +3 -0
  171. package/cjs/tuple/tuple_plus.pad_start.js.map +1 -0
  172. package/cjs/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  173. package/cjs/type-guard/is_type.d.ts.map +1 -0
  174. package/cjs/{predicates/isType.js → type-guard/is_type.js} +8 -2
  175. package/cjs/type-guard/is_type.js.map +1 -0
  176. package/esm/array/{array.d.ts → array.at.d.ts} +4 -14
  177. package/esm/array/array.at.d.ts.map +1 -0
  178. package/esm/array/array.at.js +2 -0
  179. package/esm/array/array.at.js.map +1 -0
  180. package/esm/array/array.concat.d.ts +13 -0
  181. package/esm/array/array.concat.d.ts.map +1 -0
  182. package/esm/array/array.concat.js +2 -0
  183. package/esm/array/array.concat.js.map +1 -0
  184. package/esm/array/array.entries.d.ts +17 -0
  185. package/esm/array/array.entries.d.ts.map +1 -0
  186. package/esm/array/array.entries.js +2 -0
  187. package/esm/array/array.entries.js.map +1 -0
  188. package/esm/array/array.find.d.ts +21 -0
  189. package/esm/array/array.find.d.ts.map +1 -0
  190. package/esm/array/array.find.js +2 -0
  191. package/esm/array/array.find.js.map +1 -0
  192. package/esm/array/array.find_last.d.ts +17 -0
  193. package/esm/array/array.find_last.d.ts.map +1 -0
  194. package/esm/array/array.find_last.js +2 -0
  195. package/esm/array/array.find_last.js.map +1 -0
  196. package/esm/array/array.reverse.d.ts +2 -0
  197. package/esm/array/array.reverse.d.ts.map +1 -0
  198. package/esm/array/array.reverse.js +2 -0
  199. package/esm/array/array.reverse.js.map +1 -0
  200. package/esm/array/array.some.d.ts +29 -0
  201. package/esm/array/array.some.d.ts.map +1 -0
  202. package/esm/array/array.some.js +2 -0
  203. package/esm/array/array.some.js.map +1 -0
  204. package/esm/array/array_index.d.ts +8 -8
  205. package/esm/array/array_index.d.ts.map +1 -1
  206. package/esm/array/array_plus.d.ts +9 -1
  207. package/esm/array/array_plus.d.ts.map +1 -1
  208. package/esm/array/array_plus.split_at.d.ts +35 -0
  209. package/esm/array/array_plus.split_at.d.ts.map +1 -0
  210. package/esm/array/array_plus.split_at.js +2 -0
  211. package/esm/array/array_plus.split_at.js.map +1 -0
  212. package/esm/array/drop.d.ts +2 -2
  213. package/esm/array/drop.d.ts.map +1 -1
  214. package/esm/array/index.d.ts +4 -5
  215. package/esm/array/index.d.ts.map +1 -1
  216. package/esm/array/index.js +4 -5
  217. package/esm/array/index.js.map +1 -1
  218. package/esm/array/pad_start.d.ts +32 -0
  219. package/esm/array/pad_start.d.ts.map +1 -0
  220. package/esm/array/pad_start.js +2 -0
  221. package/esm/array/pad_start.js.map +1 -0
  222. package/esm/assertion/assert_type.d.ts +3 -0
  223. package/esm/assertion/assert_type.d.ts.map +1 -1
  224. package/esm/assertion/assert_type.js +3 -0
  225. package/esm/assertion/assert_type.js.map +1 -1
  226. package/esm/bigint/cast.d.ts +10 -0
  227. package/esm/bigint/cast.d.ts.map +1 -0
  228. package/esm/bigint/cast.js +2 -0
  229. package/esm/bigint/cast.js.map +1 -0
  230. package/esm/equal/equal.d.ts +51 -3
  231. package/esm/equal/equal.d.ts.map +1 -1
  232. package/esm/functional/Maybe.d.ts +2 -2
  233. package/esm/functional/Maybe.d.ts.map +1 -1
  234. package/esm/index.d.ts +16 -7
  235. package/esm/index.d.ts.map +1 -1
  236. package/esm/index.js +5 -0
  237. package/esm/index.js.map +1 -1
  238. package/esm/math/abs.d.ts +6 -0
  239. package/esm/math/abs.d.ts.map +1 -0
  240. package/esm/math/abs.js +2 -0
  241. package/esm/math/abs.js.map +1 -0
  242. package/esm/math/add.d.ts +7 -0
  243. package/esm/math/add.d.ts.map +1 -0
  244. package/esm/math/add.js +2 -0
  245. package/esm/math/add.js.map +1 -0
  246. package/esm/math/greater_than.d.ts +4 -0
  247. package/esm/math/greater_than.d.ts.map +1 -0
  248. package/esm/math/greater_than.js +2 -0
  249. package/esm/math/greater_than.js.map +1 -0
  250. package/esm/math/index.d.ts +6 -6
  251. package/esm/math/index.d.ts.map +1 -1
  252. package/esm/math/math_plus.d.ts +5 -0
  253. package/esm/math/math_plus.d.ts.map +1 -0
  254. package/esm/math/math_plus.js +2 -0
  255. package/esm/math/math_plus.js.map +1 -0
  256. package/esm/math/math_plus.to_negative.d.ts +13 -0
  257. package/esm/math/math_plus.to_negative.d.ts.map +1 -0
  258. package/esm/math/math_plus.to_negative.js +2 -0
  259. package/esm/math/math_plus.to_negative.js.map +1 -0
  260. package/esm/math/max.d.ts +4 -0
  261. package/esm/math/max.d.ts.map +1 -0
  262. package/esm/math/max.js +2 -0
  263. package/esm/math/max.js.map +1 -0
  264. package/esm/math/multiply.d.ts +6 -0
  265. package/esm/math/multiply.d.ts.map +1 -0
  266. package/esm/math/multiply.js +2 -0
  267. package/esm/math/multiply.js.map +1 -0
  268. package/esm/math/numeric_struct.d.ts +1480 -0
  269. package/esm/math/numeric_struct.d.ts.map +1 -0
  270. package/esm/math/numeric_struct.js +2 -0
  271. package/esm/math/numeric_struct.js.map +1 -0
  272. package/esm/math/subtract.d.ts +7 -0
  273. package/esm/math/subtract.d.ts.map +1 -0
  274. package/esm/math/subtract.js +2 -0
  275. package/esm/math/subtract.js.map +1 -0
  276. package/esm/nominal/brand.js +1 -1
  277. package/esm/nominal/brand.js.map +1 -1
  278. package/esm/nominal/flavor.js +1 -1
  279. package/esm/nominal/flavor.js.map +1 -1
  280. package/esm/number/cast.d.ts +10 -0
  281. package/esm/number/cast.d.ts.map +1 -0
  282. package/esm/number/cast.js +2 -0
  283. package/esm/number/cast.js.map +1 -0
  284. package/esm/number/number_array.d.ts +1 -2
  285. package/esm/number/number_array.d.ts.map +1 -1
  286. package/esm/number/number_array.js +14 -0
  287. package/esm/number/number_array.js.map +1 -1
  288. package/esm/number/number_plus.d.ts +4 -5
  289. package/esm/number/number_plus.d.ts.map +1 -1
  290. package/esm/number/strict_number_type.d.ts +12 -0
  291. package/esm/number/strict_number_type.d.ts.map +1 -1
  292. package/esm/numeric/cast.d.ts +27 -0
  293. package/esm/numeric/cast.d.ts.map +1 -0
  294. package/esm/numeric/cast.js +2 -0
  295. package/esm/numeric/cast.js.map +1 -0
  296. package/{cjs/number → esm/numeric}/integer.d.ts +2 -0
  297. package/esm/numeric/integer.d.ts.map +1 -0
  298. package/esm/{number → numeric}/integer.js.map +1 -1
  299. package/esm/numeric/negative.d.ts.map +1 -0
  300. package/esm/{number → numeric}/negative.js.map +1 -1
  301. package/esm/numeric/numeric_plus.d.ts +5 -0
  302. package/esm/numeric/numeric_plus.d.ts.map +1 -0
  303. package/esm/numeric/numeric_plus.js +2 -0
  304. package/esm/numeric/numeric_plus.js.map +1 -0
  305. package/esm/numeric/numeric_type.d.ts.map +1 -0
  306. package/esm/{number → numeric}/numeric_type.js.map +1 -1
  307. package/esm/{number → numeric}/positive.d.ts +2 -2
  308. package/esm/numeric/positive.d.ts.map +1 -0
  309. package/esm/{number → numeric}/positive.js.map +1 -1
  310. package/esm/object/ANotB.d.ts +3 -3
  311. package/esm/object/ANotB.d.ts.map +1 -1
  312. package/esm/object/Partial.d.ts +6 -0
  313. package/esm/object/Partial.d.ts.map +1 -1
  314. package/esm/object/Required.d.ts +4 -0
  315. package/esm/object/Required.d.ts.map +1 -1
  316. package/esm/object/index.d.ts +1 -1
  317. package/esm/object/index.d.ts.map +1 -1
  318. package/esm/object/object_type.d.ts +1 -1
  319. package/esm/object/split.d.ts +3 -1
  320. package/esm/object/split.d.ts.map +1 -1
  321. package/esm/object/split.js.map +1 -1
  322. package/esm/predicates/CanAssign.d.ts +35 -0
  323. package/esm/predicates/CanAssign.d.ts.map +1 -1
  324. package/esm/predicates/CanAssign.js.map +1 -1
  325. package/esm/predicates/Extends.d.ts +2 -2
  326. package/esm/predicates/Extends.d.ts.map +1 -1
  327. package/esm/predicates/index.d.ts +0 -1
  328. package/esm/predicates/index.d.ts.map +1 -1
  329. package/esm/predicates/index.js +0 -1
  330. package/esm/predicates/index.js.map +1 -1
  331. package/esm/testing/test_type.d.ts +125 -50
  332. package/esm/testing/test_type.d.ts.map +1 -1
  333. package/esm/testing/test_type.js +4 -141
  334. package/esm/testing/test_type.js.map +1 -1
  335. package/esm/tuple/create_tuple.d.ts +28 -0
  336. package/esm/tuple/create_tuple.d.ts.map +1 -0
  337. package/esm/{array → tuple}/create_tuple.js.map +1 -1
  338. package/esm/tuple/tuple_plus.d.ts +2 -0
  339. package/esm/tuple/tuple_plus.d.ts.map +1 -0
  340. package/esm/tuple/tuple_plus.js +2 -0
  341. package/esm/tuple/tuple_plus.js.map +1 -0
  342. package/esm/tuple/tuple_plus.pad_start.d.ts +22 -0
  343. package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -0
  344. package/esm/tuple/tuple_plus.pad_start.js +2 -0
  345. package/esm/tuple/tuple_plus.pad_start.js.map +1 -0
  346. package/esm/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
  347. package/esm/type-guard/is_type.d.ts.map +1 -0
  348. package/esm/{predicates/isType.js → type-guard/is_type.js} +8 -2
  349. package/esm/type-guard/is_type.js.map +1 -0
  350. package/package.json +1 -1
  351. package/ts/array/{array.ts → array.at.ts} +10 -15
  352. package/ts/array/array.concat.ts +12 -0
  353. package/ts/array/array.entries.ts +24 -0
  354. package/ts/array/array.find.ts +32 -0
  355. package/ts/array/array.find_last.ts +27 -0
  356. package/ts/array/array.reverse.ts +16 -0
  357. package/ts/array/array.some.ts +53 -0
  358. package/ts/array/array_index.ts +16 -10
  359. package/ts/array/array_plus.split_at.ts +45 -0
  360. package/ts/array/array_plus.ts +9 -1
  361. package/ts/array/drop.ts +2 -2
  362. package/ts/array/index.ts +4 -5
  363. package/ts/array/pad_start.ts +43 -0
  364. package/ts/array/readme.md +184 -4
  365. package/ts/assertion/assert_type.ts +6 -0
  366. package/ts/assertion/readme.md +132 -1
  367. package/ts/bigint/cast.ts +13 -0
  368. package/ts/bigint/readme.md +17 -17
  369. package/ts/equal/equal.ts +53 -3
  370. package/ts/equal/readme.md +30 -16
  371. package/ts/functional/Maybe.ts +2 -2
  372. package/ts/index.ts +22 -24
  373. package/ts/math/README.md +97 -7
  374. package/ts/math/abs.ts +18 -0
  375. package/ts/math/add.ts +14 -0
  376. package/ts/math/greater_than.ts +12 -0
  377. package/ts/math/index.ts +7 -6
  378. package/ts/math/math_plus.to_negative.ts +22 -0
  379. package/ts/math/math_plus.ts +4 -0
  380. package/ts/math/max.ts +13 -0
  381. package/ts/math/multiply.ts +12 -0
  382. package/ts/math/numeric_struct.ts +656 -0
  383. package/ts/math/subtract.ts +14 -0
  384. package/ts/nominal/brand.ts +1 -1
  385. package/ts/nominal/flavor.ts +1 -1
  386. package/ts/number/cast.ts +17 -0
  387. package/ts/number/number_array.ts +14 -14
  388. package/ts/number/number_plus.ts +6 -6
  389. package/ts/number/readme.md +0 -108
  390. package/ts/number/strict_number_type.ts +12 -0
  391. package/ts/numeric/cast.ts +28 -0
  392. package/ts/{number → numeric}/integer.ts +2 -0
  393. package/ts/numeric/numeric_plus.ts +12 -0
  394. package/ts/{number → numeric}/positive.ts +2 -2
  395. package/ts/numeric/readme.md +115 -0
  396. package/ts/object/ANotB.ts +3 -3
  397. package/ts/object/Partial.ts +5 -0
  398. package/ts/object/Required.ts +4 -0
  399. package/ts/object/index.ts +1 -1
  400. package/ts/object/object_type.ts +1 -1
  401. package/ts/object/split.ts +3 -1
  402. package/ts/predicates/CanAssign.ts +46 -0
  403. package/ts/predicates/Extends.ts +2 -2
  404. package/ts/predicates/index.ts +0 -1
  405. package/ts/testing/test_type.ts +131 -88
  406. package/ts/tuple/create_tuple.ts +42 -0
  407. package/ts/tuple/tuple_plus.pad_start.ts +42 -0
  408. package/ts/tuple/tuple_plus.ts +1 -0
  409. package/ts/{predicates/isType.ts → type-guard/is_type.ts} +11 -3
  410. package/ts/type-guard/readme.md +37 -0
  411. package/cjs/array/array.d.ts.map +0 -1
  412. package/cjs/array/array.js.map +0 -1
  413. package/cjs/array/create_tuple.d.ts +0 -11
  414. package/cjs/array/create_tuple.d.ts.map +0 -1
  415. package/cjs/array/find_first.d.ts +0 -6
  416. package/cjs/array/find_first.d.ts.map +0 -1
  417. package/cjs/array/find_first.js.map +0 -1
  418. package/cjs/array/find_last.d.ts +0 -2
  419. package/cjs/array/find_last.d.ts.map +0 -1
  420. package/cjs/array/find_last.js.map +0 -1
  421. package/cjs/array/pad_left.d.ts +0 -6
  422. package/cjs/array/pad_left.d.ts.map +0 -1
  423. package/cjs/array/pad_left.js.map +0 -1
  424. package/cjs/array/some.d.ts +0 -8
  425. package/cjs/array/some.d.ts.map +0 -1
  426. package/cjs/array/some.js.map +0 -1
  427. package/cjs/math/Abs.d.ts +0 -3
  428. package/cjs/math/Abs.d.ts.map +0 -1
  429. package/cjs/math/Abs.js.map +0 -1
  430. package/cjs/math/Add.d.ts +0 -19
  431. package/cjs/math/Add.d.ts.map +0 -1
  432. package/cjs/math/Add.js.map +0 -1
  433. package/cjs/math/Digit.d.ts +0 -100
  434. package/cjs/math/Digit.d.ts.map +0 -1
  435. package/cjs/math/Digit.js +0 -3
  436. package/cjs/math/Digit.js.map +0 -1
  437. package/cjs/math/GreaterThan.d.ts +0 -13
  438. package/cjs/math/GreaterThan.d.ts.map +0 -1
  439. package/cjs/math/GreaterThan.js +0 -3
  440. package/cjs/math/GreaterThan.js.map +0 -1
  441. package/cjs/math/Max.d.ts +0 -4
  442. package/cjs/math/Max.d.ts.map +0 -1
  443. package/cjs/math/Max.js.map +0 -1
  444. package/cjs/math/Subtract.d.ts +0 -19
  445. package/cjs/math/Subtract.d.ts.map +0 -1
  446. package/cjs/math/Subtract.js +0 -3
  447. package/cjs/math/Subtract.js.map +0 -1
  448. package/cjs/number/integer.d.ts.map +0 -1
  449. package/cjs/number/negative.d.ts.map +0 -1
  450. package/cjs/number/numeric_type.d.ts.map +0 -1
  451. package/cjs/number/positive.d.ts.map +0 -1
  452. package/cjs/predicates/isType.d.ts.map +0 -1
  453. package/cjs/predicates/isType.js.map +0 -1
  454. package/esm/array/array.d.ts.map +0 -1
  455. package/esm/array/array.js +0 -2
  456. package/esm/array/array.js.map +0 -1
  457. package/esm/array/create_tuple.d.ts +0 -11
  458. package/esm/array/create_tuple.d.ts.map +0 -1
  459. package/esm/array/find_first.d.ts +0 -6
  460. package/esm/array/find_first.d.ts.map +0 -1
  461. package/esm/array/find_first.js +0 -2
  462. package/esm/array/find_first.js.map +0 -1
  463. package/esm/array/find_last.d.ts +0 -2
  464. package/esm/array/find_last.d.ts.map +0 -1
  465. package/esm/array/find_last.js +0 -2
  466. package/esm/array/find_last.js.map +0 -1
  467. package/esm/array/pad_left.d.ts +0 -6
  468. package/esm/array/pad_left.d.ts.map +0 -1
  469. package/esm/array/pad_left.js +0 -2
  470. package/esm/array/pad_left.js.map +0 -1
  471. package/esm/array/some.d.ts +0 -8
  472. package/esm/array/some.d.ts.map +0 -1
  473. package/esm/array/some.js +0 -2
  474. package/esm/array/some.js.map +0 -1
  475. package/esm/math/Abs.d.ts +0 -3
  476. package/esm/math/Abs.d.ts.map +0 -1
  477. package/esm/math/Abs.js +0 -2
  478. package/esm/math/Abs.js.map +0 -1
  479. package/esm/math/Add.d.ts +0 -19
  480. package/esm/math/Add.d.ts.map +0 -1
  481. package/esm/math/Add.js +0 -2
  482. package/esm/math/Add.js.map +0 -1
  483. package/esm/math/Digit.d.ts +0 -100
  484. package/esm/math/Digit.d.ts.map +0 -1
  485. package/esm/math/Digit.js +0 -2
  486. package/esm/math/Digit.js.map +0 -1
  487. package/esm/math/GreaterThan.d.ts +0 -13
  488. package/esm/math/GreaterThan.d.ts.map +0 -1
  489. package/esm/math/GreaterThan.js +0 -2
  490. package/esm/math/GreaterThan.js.map +0 -1
  491. package/esm/math/Max.d.ts +0 -4
  492. package/esm/math/Max.d.ts.map +0 -1
  493. package/esm/math/Max.js +0 -2
  494. package/esm/math/Max.js.map +0 -1
  495. package/esm/math/Subtract.d.ts +0 -19
  496. package/esm/math/Subtract.d.ts.map +0 -1
  497. package/esm/math/Subtract.js +0 -2
  498. package/esm/math/Subtract.js.map +0 -1
  499. package/esm/number/integer.d.ts.map +0 -1
  500. package/esm/number/negative.d.ts.map +0 -1
  501. package/esm/number/numeric_type.d.ts.map +0 -1
  502. package/esm/number/positive.d.ts.map +0 -1
  503. package/esm/predicates/isType.d.ts.map +0 -1
  504. package/esm/predicates/isType.js.map +0 -1
  505. package/ts/array/create_tuple.ts +0 -17
  506. package/ts/array/find_first.ts +0 -16
  507. package/ts/array/find_last.ts +0 -11
  508. package/ts/array/pad_left.ts +0 -16
  509. package/ts/array/some.ts +0 -33
  510. package/ts/math/Abs.ts +0 -7
  511. package/ts/math/Add.ts +0 -58
  512. package/ts/math/Digit.ts +0 -152
  513. package/ts/math/GreaterThan.ts +0 -55
  514. package/ts/math/Max.ts +0 -10
  515. package/ts/math/Subtract.ts +0 -57
  516. /package/cjs/{number → numeric}/integer.js +0 -0
  517. /package/cjs/{number → numeric}/negative.d.ts +0 -0
  518. /package/cjs/{number → numeric}/negative.js +0 -0
  519. /package/cjs/{number → numeric}/numeric_type.d.ts +0 -0
  520. /package/cjs/{number → numeric}/numeric_type.js +0 -0
  521. /package/cjs/{number → numeric}/positive.js +0 -0
  522. /package/cjs/{array → tuple}/create_tuple.js +0 -0
  523. /package/esm/{number → numeric}/integer.js +0 -0
  524. /package/esm/{number → numeric}/negative.d.ts +0 -0
  525. /package/esm/{number → numeric}/negative.js +0 -0
  526. /package/esm/{number → numeric}/numeric_type.d.ts +0 -0
  527. /package/esm/{number → numeric}/numeric_type.js +0 -0
  528. /package/esm/{number → numeric}/positive.js +0 -0
  529. /package/esm/{array → tuple}/create_tuple.js +0 -0
  530. /package/ts/{number → numeric}/negative.ts +0 -0
  531. /package/ts/{number → numeric}/numeric_type.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  // By Drew Colthorp, <https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/#comment-604580>
2
2
  // <https://gist.github.com/dcolthorp/aa21cf87d847ae9942106435bf47565d>
3
3
 
4
- import { isType } from '../predicates/isType.js'
4
+ import { isType } from '../type-guard/is_type.js'
5
5
  import type { Widen } from '../utils/index.js'
6
6
  import { typeSym, valueSym } from './constants.js'
7
7
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Cast a string to a number literal type if possible.
3
+ *
4
+ * ```ts
5
+ * StringToNumber<'1'> // 1
6
+ * StringToNumber<'-1'> // -1
7
+ * ```
8
+ */
9
+ export type StringToNumber<S extends string, Fail = never> = S extends `-0`
10
+ ? 0
11
+ : S extends `${infer W}.0`
12
+ ? StringToNumber<W>
13
+ : S extends `${infer W}.${infer F}0`
14
+ ? StringToNumber<`${W}.${F}`>
15
+ : S extends `${infer N extends number}`
16
+ ? N
17
+ : Fail
@@ -1,15 +1,15 @@
1
- import type { Add, IsStrictNumber } from '../index.js'
1
+ // import type { Add, IsStrictNumber } from '../index.js'
2
2
 
3
- export type Sum<A extends number[], Fail = never> = IsStrictNumber<
4
- A['length'],
5
- Fail,
6
- A['length'] extends 0
7
- ? 0
8
- : A['length'] extends 1
9
- ? A[0]
10
- : A['length'] extends 2
11
- ? Add<A[0], A[1]>
12
- : A extends [infer F extends number, infer S extends number, ...infer Tail extends number[]]
13
- ? Sum<[Add<F, S>, ...Tail]>
14
- : never
15
- >
3
+ // export type Sum<A extends number[], Fail = never> = IsStrictNumber<
4
+ // A['length'],
5
+ // Fail,
6
+ // A['length'] extends 0
7
+ // ? 0
8
+ // : A['length'] extends 1
9
+ // ? A[0]
10
+ // : A['length'] extends 2
11
+ // ? Add<A[0], A[1]>
12
+ // : A extends [infer F extends number, infer S extends number, ...infer Tail extends number[]]
13
+ // ? Sum<[Add<F, S>, ...Tail]>
14
+ // : never
15
+ // >
@@ -1,7 +1,5 @@
1
- export type { Integer, IsInteger, IsNotInteger, IsWhole, NotInteger } from './integer.js'
2
- export type { IsNegative, IsNotNegative, Negative, NotNegative } from './negative.js'
3
- export type { Sum } from './number_array.js'
4
- export type { IsNotNumber, IsNumber, NotNumberType, NumberType } from './number_type.js'
1
+ export type { Integer, IsInteger, IsNotInteger, IsWhole, NotInteger } from '../numeric/integer.js'
2
+ export type { IsNegative, IsNotNegative, Negative, NotNegative } from '../numeric/negative.js'
5
3
  export type {
6
4
  IsNotNumeric,
7
5
  IsNumeric,
@@ -9,8 +7,10 @@ export type {
9
7
  Numeric,
10
8
  NumericType,
11
9
  Zero
12
- } from './numeric_type.js'
13
- export type { IsNotPositive, IsPositive, NonPositive, Positive } from './positive.js'
10
+ } from '../numeric/numeric_type.js'
11
+ export type { IsNotPositive, IsPositive, NonPositive, Positive } from '../numeric/positive.js'
12
+ // export type { Sum } from './number_array.js'
13
+ export type { IsNotNumber, IsNumber, NotNumberType, NumberType } from './number_type.js'
14
14
  export type {
15
15
  IsNotStrictNumber,
16
16
  IsStrictNumber,
@@ -40,114 +40,6 @@ type R = StrictNumberType<unknown> // never
40
40
  - [`NotStrictNumberType<T, Then = T, Else = never>`](strict_number_type.ts#L50): check if `T` is not `number`.
41
41
  - [`IsNotStrictNumber<T, Then = true, Else = false>`](strict_number_type.ts#L65): is `T` not `number`.
42
42
 
43
- ---
44
-
45
- `Numeric` type is either `number` or `bigint`.
46
-
47
- The `NumericType<T>` and friends are used to check if `T` is `number` or `bigint`.
48
-
49
- ```ts
50
- import type { NumericType } from 'type-plus'
51
-
52
- type R = NumericType<number> // number
53
- type R = NumericType<bigint> // bigint
54
- type R = NumericType<1> // 1
55
- type R = NumericType<1n> // 1n
56
-
57
- type R = NumericType<never> // never
58
- ```
59
-
60
- - [`NumericType<T, Then = T, Else = never>`](numeric_type.ts#L27): check if `T` is `number` or `bigint`.
61
- - [`IsNumeric<T, Then = true, Else = false>`](numeric_type.ts#L42): is `T` `number` or `bigint`.
62
- - [`NotNumericType<T, Then = T, Else = never>`](numeric_type.ts#L57): check if `T` is not `number` nor `bigint`.
63
- - [`IsNotNumeric<T, Then = true, Else = false>`](numeric_type.ts#L72): is `T` not `number` nor `bigint`.
64
-
65
- ---
66
-
67
- `Integer<T>` and friends are used to check if `T` is an integer.
68
-
69
- ```ts
70
- import type { Integer } from 'type-plus'
71
-
72
- type R = Integer<1> // 1
73
- type R = Integer<1.0> // 1.0
74
-
75
- type R = Integer<1.1> // never
76
- ```
77
-
78
- - [`Integer<T, Then = T, Else = never>`](integer.ts#L17): check if `T` is an integer.
79
- - [`IsInteger<T, Then = true, Else = false>`](integer.ts#L36): is `T` an integer.
80
- - [`NotIntegerType<T, Then = T, Else = never>`](integer.ts#L51): check if `T` is not an integer.
81
- - [`IsNotInteger<T, Then = true, Else = false>`](integer.ts#L66): is `T` not an integer.
82
- - [`IsWhole<T, Then = true, Else = false>`](integer.ts#L81): same as `Integer<T>`, will be deprecated in the future.
83
-
84
- ---
85
-
86
- `Positive<T>` and friends are used to check if `T` is a positive numeric value.
87
-
88
- The `number` and `bigint` can be considered as a union of all positive and negative numeric literals.
89
-
90
- That is why `IsPositive<T>` will yield `boolean` as the union is distributive.
91
- `Positive<T>` returns `T` for `number` and `bigint` for the same reason.
92
- It is a bit confusing but it is correct as it really returns `T | never`,
93
- which resolves to `T`.
94
-
95
- This behavior is different than `TrueType<T>` which `TrueType<boolean>` returns `never`.
96
-
97
- This is because `TrueType<T>` is checking for the exect `true` type,
98
- while `Positive<T>` is checking for a criteria of types (i.e. a set).
99
-
100
- ```ts
101
- import type { Positive } from 'type-plus'
102
-
103
- type R = Positive<1> // 1
104
- type R = Positive<1.0> // 1.0
105
- type R = Positive<1n> // 1n
106
-
107
- type R = Positive<-1> // never
108
- type R = Positive<'1'> // never
109
- ```
110
-
111
- - [`Positive<T, Then = T, Else = never>`](positive.ts#L17): check if `T` is a positive numeric value.
112
- - [`IsPositive<T, Then = true, Else = false>`](positive.ts#L40): is `T` a positive numeric value.
113
- - [`NotPositiveType<T, Then = T, Else = never>`](positive.ts#L54): check if `T` is not a positive numeric value.
114
- - [`IsNotPositive<T, Then = true, Else = false>`](positive.ts#L68): is `T` not a positive numeric value.
115
-
116
- ---
117
-
118
- `Negative<T>` and friends are used to check if `T` is a negative numeric value.
119
-
120
- The `number` and `bigint` can be considered as a union of all negative and negative numeric literals.
121
-
122
- That is why `IsNegative<T>` will yield `boolean` as the union is distributive.
123
- `Negative<T>` returns `T` for `number` and `bigint` for the same reason.
124
- It is a bit confusing but it is correct as it really returns `T | never`,
125
- which resolves to `T`.
126
-
127
- This behavior is different than `TrueType<T>` which `TrueType<boolean>` returns `never`.
128
-
129
- This is because `TrueType<T>` is checking for the exect `true` type,
130
- while `Negative<T>` is checking for a criteria of types (i.e. a set).
131
-
132
- ```ts
133
- import type { Negative } from 'type-plus'
134
-
135
- type R = Negative<1> // never
136
- type R = Negative<1.0> // never
137
- type R = Negative<1n> // never
138
-
139
- type R = Negative<number> // number
140
- type R = Negative<any> // any
141
-
142
- type R = Negative<-1> // -1
143
- type R = Negative<'1'> // '1'
144
- ```
145
-
146
- - [`Negative<T, Then = T, Else = never>`](negative.ts#L21): check if `T` is a negative numeric value.
147
- - [`IsNegative<T, Then = true, Else = false>`](negative.ts#L57): is `T` a negative numeric value.
148
- - [`NotNegativeType<T, Then = T, Else = never>`](negative.ts#L75): check if `T` is not a negative numeric value.
149
- - [`IsNotNegative<T, Then = true, Else = false>`](negative.ts#L109): is `T` not a negative numeric value.
150
-
151
43
  ## References
152
44
 
153
45
  - [Handbook]
@@ -3,6 +3,11 @@ import type { IsAny } from '../any/any_type.js'
3
3
  /**
4
4
  * Check if the type `T` is exactly the type `number` and not numeric literals.
5
5
  *
6
+ * Note that if `T` is guaranteed to be a `number`, e.g. `SomeArray['length']`,
7
+ *
8
+ * A simple `number extends SomeArray['length'] ? Then, Else` is sufficient.
9
+ *
10
+ * @example
6
11
  * ```ts
7
12
  * type R = StrictNumberType<number> // true
8
13
  * type R = StrictNumberType<1> // false
@@ -20,6 +25,11 @@ export type StrictNumberType<T, Then = T, Else = never> = IsAny<
20
25
  /**
21
26
  * Is the type `T` exactly the type `number` and not numeric literals.
22
27
  *
28
+ * Note that if `T` is guaranteed to be a `number`, e.g. `SomeArray['length']`,
29
+ *
30
+ * A simple `number extends SomeArray['length'] ? Then, Else` is sufficient.
31
+ *
32
+ * @example
23
33
  * ```ts
24
34
  * type R = IsStrictNumber<number> // true
25
35
  * type R = IsStrictNumber<1> // false
@@ -33,6 +43,7 @@ export type IsStrictNumber<T, Then = true, Else = false> = StrictNumberType<T, T
33
43
  /**
34
44
  * Check if the type `T` is not the type `number` or numeric literals.
35
45
  *
46
+ * @example
36
47
  * ```ts
37
48
  * type R = NotStrictNumberType<number> // false
38
49
  * type R = NotStrictNumberType<1> // true
@@ -46,6 +57,7 @@ export type NotStrictNumberType<T, Then = T, Else = never> = StrictNumberType<T,
46
57
  /**
47
58
  * Is the type `T` not the type `number` or numeric literals.
48
59
  *
60
+ * @example
49
61
  * ```ts
50
62
  * type R = IsNotStrictNumber<number> // false
51
63
  * type R = IsNotStrictNumber<1> // true
@@ -0,0 +1,28 @@
1
+ import type { StringToBigint } from '../bigint/cast.js'
2
+ import type { StringToNumber } from '../number/cast.js'
3
+
4
+ /**
5
+ * Cast a string to a numeric literal type (number or bigint) if possible.
6
+ *
7
+ * ```ts
8
+ * StringToNumeric<'1'> // 1
9
+ * StringToNumeric<'1n'> // 1n
10
+ * StringToNumeric<'-1'> // -1
11
+ * StringToNumeric<'-1n'> // -1n
12
+ * ```
13
+ */
14
+ export type StringToNumeric<S extends string, Fail = never> = StringToBigint<S, StringToNumber<S, Fail>>
15
+
16
+ /**
17
+ * Cast a numeric literal type (number or bigint) to string.
18
+ *
19
+ * ```ts
20
+ * NumericToString<1> // '1'
21
+ * NumericToString<1.23> // '1.23'
22
+ * NumericToString<0.00123> // '0.00123'
23
+ * NumericToString<1n> // '1n'
24
+ * NumericToString<-1> // '-1'
25
+ * NumericToString<-1n> // '-1n'
26
+ * ```
27
+ */
28
+ export type NumericToString<N extends number | bigint> = N extends number ? `${N}` : `${N}n`
@@ -62,6 +62,8 @@ export type IsNotInteger<T, Then = true, Else = false> = NotInteger<T, Else, The
62
62
  /**
63
63
  * Check if T is an integer, including bigint.
64
64
  *
65
+ * @deprecated use `IsInteger` instead
66
+ *
65
67
  * ```ts
66
68
  * type R = IsWhole<0> // 0
67
69
  * type R = IsWhole<1n> // 1n
@@ -0,0 +1,12 @@
1
+ export type { Integer, IsInteger, IsNotInteger, IsWhole, NotInteger } from './integer.js'
2
+ export type { IsNegative, IsNotNegative, Negative, NotNegative } from './negative.js'
3
+ export type {
4
+ IsNotNumeric,
5
+ IsNumeric,
6
+ NotNumericType,
7
+ Numeric,
8
+ NumericType,
9
+ Zero
10
+ } from './numeric_type.js'
11
+ export type { IsNotPositive, IsPositive, NonPositive, Positive } from './positive.js'
12
+
@@ -1,5 +1,5 @@
1
- import { IsAny } from '../any/any_type.js'
2
- import { IsNever } from '../index.js'
1
+ import type { IsAny } from '../any/any_type.js'
2
+ import type { IsNever } from '../index.js'
3
3
 
4
4
  /**
5
5
  * Check if `T` is a positive numeric type.
@@ -0,0 +1,115 @@
1
+ # number
2
+
3
+ ## Type Checking
4
+
5
+ `Numeric` type is either `number` or `bigint`.
6
+
7
+ The `NumericType<T>` and friends are used to check if `T` is `number` or `bigint`.
8
+
9
+ ```ts
10
+ import type { NumericType } from 'type-plus'
11
+
12
+ type R = NumericType<number> // number
13
+ type R = NumericType<bigint> // bigint
14
+ type R = NumericType<1> // 1
15
+ type R = NumericType<1n> // 1n
16
+
17
+ type R = NumericType<never> // never
18
+ ```
19
+
20
+ - [`NumericType<T, Then = T, Else = never>`](numeric_type.ts#L27): check if `T` is `number` or `bigint`.
21
+ - [`IsNumeric<T, Then = true, Else = false>`](numeric_type.ts#L42): is `T` `number` or `bigint`.
22
+ - [`NotNumericType<T, Then = T, Else = never>`](numeric_type.ts#L57): check if `T` is not `number` nor `bigint`.
23
+ - [`IsNotNumeric<T, Then = true, Else = false>`](numeric_type.ts#L72): is `T` not `number` nor `bigint`.
24
+
25
+ ---
26
+
27
+ `Integer<T>` and friends are used to check if `T` is an integer.
28
+
29
+ ```ts
30
+ import type { Integer } from 'type-plus'
31
+
32
+ type R = Integer<1> // 1
33
+ type R = Integer<1.0> // 1.0
34
+
35
+ type R = Integer<1.1> // never
36
+ ```
37
+
38
+ - [`Integer<T, Then = T, Else = never>`](integer.ts#L17): check if `T` is an integer.
39
+ - [`IsInteger<T, Then = true, Else = false>`](integer.ts#L36): is `T` an integer.
40
+ - [`NotIntegerType<T, Then = T, Else = never>`](integer.ts#L51): check if `T` is not an integer.
41
+ - [`IsNotInteger<T, Then = true, Else = false>`](integer.ts#L66): is `T` not an integer.
42
+ - [`IsWhole<T, Then = true, Else = false>`](integer.ts#L81): same as `Integer<T>`, will be deprecated in the future.
43
+
44
+ ---
45
+
46
+ `Positive<T>` and friends are used to check if `T` is a positive numeric value.
47
+
48
+ The `number` and `bigint` can be considered as a union of all positive and negative numeric literals.
49
+
50
+ That is why `IsPositive<T>` will yield `boolean` as the union is distributive.
51
+ `Positive<T>` returns `T` for `number` and `bigint` for the same reason.
52
+ It is a bit confusing but it is correct as it really returns `T | never`,
53
+ which resolves to `T`.
54
+
55
+ This behavior is different than `TrueType<T>` which `TrueType<boolean>` returns `never`.
56
+
57
+ This is because `TrueType<T>` is checking for the exact `true` type,
58
+ while `Positive<T>` is checking for a criteria of types (i.e. a set).
59
+
60
+ ```ts
61
+ import type { Positive } from 'type-plus'
62
+
63
+ type R = Positive<1> // 1
64
+ type R = Positive<1.0> // 1.0
65
+ type R = Positive<1n> // 1n
66
+
67
+ type R = Positive<-1> // never
68
+ type R = Positive<'1'> // never
69
+ ```
70
+
71
+ - [`Positive<T, Then = T, Else = never>`](positive.ts#L17): check if `T` is a positive numeric value.
72
+ - [`IsPositive<T, Then = true, Else = false>`](positive.ts#L40): is `T` a positive numeric value.
73
+ - [`NotPositiveType<T, Then = T, Else = never>`](positive.ts#L54): check if `T` is not a positive numeric value.
74
+ - [`IsNotPositive<T, Then = true, Else = false>`](positive.ts#L68): is `T` not a positive numeric value.
75
+
76
+ ---
77
+
78
+ `Negative<T>` and friends are used to check if `T` is a negative numeric value.
79
+
80
+ The `number` and `bigint` can be considered as a union of all negative and negative numeric literals.
81
+
82
+ That is why `IsNegative<T>` will yield `boolean` as the union is distributive.
83
+ `Negative<T>` returns `T` for `number` and `bigint` for the same reason.
84
+ It is a bit confusing but it is correct as it really returns `T | never`,
85
+ which resolves to `T`.
86
+
87
+ This behavior is different than `TrueType<T>` which `TrueType<boolean>` returns `never`.
88
+
89
+ This is because `TrueType<T>` is checking for the exact `true` type,
90
+ while `Negative<T>` is checking for a criteria of types (i.e. a set).
91
+
92
+ ```ts
93
+ import type { Negative } from 'type-plus'
94
+
95
+ type R = Negative<1> // never
96
+ type R = Negative<1.0> // never
97
+ type R = Negative<1n> // never
98
+
99
+ type R = Negative<number> // number
100
+ type R = Negative<any> // any
101
+
102
+ type R = Negative<-1> // -1
103
+ type R = Negative<'1'> // '1'
104
+ ```
105
+
106
+ - [`Negative<T, Then = T, Else = never>`](negative.ts#L21): check if `T` is a negative numeric value.
107
+ - [`IsNegative<T, Then = true, Else = false>`](negative.ts#L57): is `T` a negative numeric value.
108
+ - [`NotNegativeType<T, Then = T, Else = never>`](negative.ts#L75): check if `T` is not a negative numeric value.
109
+ - [`IsNotNegative<T, Then = true, Else = false>`](negative.ts#L109): is `T` not a negative numeric value.
110
+
111
+ ## References
112
+
113
+ - [Handbook]
114
+
115
+ [handbook]: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean
@@ -1,9 +1,9 @@
1
- import { Equal } from '../equal/equal.js'
1
+ import type { IsEqual } from '../equal/equal.js'
2
2
  import type { AnyRecord } from './AnyRecord.js'
3
3
  import type { IsDisjoint } from './IsDisjoint.js'
4
4
  import type { KeysWithDiffType } from './KeysWithDiffType.js'
5
5
 
6
- export type ANotB<A extends AnyRecord, B extends AnyRecord> = Equal<A, B> extends true
6
+ export type ANotB<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
7
7
  ? never
8
8
  : IsDisjoint<A, B> extends true
9
9
  ? A
@@ -11,7 +11,7 @@ export type ANotB<A extends AnyRecord, B extends AnyRecord> = Equal<A, B> extend
11
11
 
12
12
  export type BNotA<A extends AnyRecord, B extends AnyRecord> = ANotB<B, A>
13
13
 
14
- export type LeftJoin<A extends AnyRecord, B extends AnyRecord> = Equal<A, B> extends true
14
+ export type LeftJoin<A extends AnyRecord, B extends AnyRecord> = IsEqual<A, B> extends true
15
15
  ? A
16
16
  : IsDisjoint<A, B> extends true
17
17
  ? A & B
@@ -2,6 +2,11 @@ import type { UnionKeys } from '../union_keys.js'
2
2
  import type { Omit } from './omit.js'
3
3
  import type { Pick } from './pick.js'
4
4
 
5
+ /**
6
+ * An alternative `Partial<T>` type that works with `exactOptionalPropertyTypes`
7
+ */
8
+ export type Partial<T> = { [P in keyof T]?: T[P] | undefined }
9
+
5
10
  /**
6
11
  * Apply `Partial<>` on the selected properties.
7
12
  */
@@ -1,5 +1,9 @@
1
1
  // Thanks [jack-williams](https://github.com/jack-williams) for the [solution](https://github.com/Microsoft/TypeScript/issues/29269#issuecomment-451602962)
2
2
 
3
+ import { NonUndefined } from '../utils/NonUndefined.js'
4
+
5
+ export type Required<T> = { [P in keyof T]-?: NonUndefined<T[P]> }
6
+
3
7
  export type RequiredPick<T, U extends keyof T> = Required<Pick<T, U>> & Pick<T, Exclude<keyof T, U>>
4
8
 
5
9
  export type RequiredExcept<T, U extends keyof T> = Required<Pick<T, Exclude<keyof T, U>>> & Pick<T, U>
@@ -8,7 +8,7 @@ export type { KeysOfOptional } from './KeyofOptional.js'
8
8
  export type { KeysWithDiffType } from './KeysWithDiffType.js'
9
9
  export type { KnownKeys } from './KnownKeys.js'
10
10
  export type { OptionalKeys } from './OptionalKeys.js'
11
- export type { PartialExcept, PartialOmit, PartialPick } from './Partial.js'
11
+ export type { Partial, PartialExcept, PartialOmit, PartialPick } from './Partial.js'
12
12
  export type { RecursiveIntersect } from './RecursiveIntersect.js'
13
13
  export type { RecursivePartial } from './RecursivePartial.js'
14
14
  export type { RecursiveRequired } from './RecursiveRequired.js'
@@ -16,7 +16,7 @@ export type ObjectType<T, Then = T, Else = never> = IsAnyOrNever<T, Else, [T] ex
16
16
  /**
17
17
  * Is `T` an `object`.
18
18
  *
19
- * Note that `Function` is also an `object`.
19
+ * Note that `Function`, `Array`, and *tuple* are also `object`.
20
20
  *
21
21
  * ```ts
22
22
  * type R = IsObject<{}> // true
@@ -2,10 +2,12 @@
2
2
  import type { AnyRecord } from './AnyRecord.js'
3
3
  import type { Omit } from './omit.js'
4
4
  import { reduceByKey } from './reduceKey.js'
5
+ import type { Partial } from './Partial.js'
6
+ import { NonUndefined } from '../utils/NonUndefined.js'
5
7
 
6
8
  type Splitter<T extends AnyRecord> = Partial<{ [k in keyof T]: T[k] | undefined }>
7
9
  export type Split<T extends AnyRecord, S extends AnyRecord> = {
8
- [k in keyof S]-?: S[k] extends undefined ? T[k] : NonNullable<T[k]> | S[k]
10
+ [k in keyof S]-?: S[k] extends undefined ? T[k] : NonNullable<T[k]> | NonUndefined<S[k]>
9
11
  }
10
12
 
11
13
  /**
@@ -3,6 +3,26 @@ import type { IsEmptyObject } from './IsEmptyObject.js'
3
3
 
4
4
  /**
5
5
  * Can `A` assign to `B`
6
+ *
7
+ * Note that when union is involved, the assignability is measured distributively.
8
+ * Meaning the result can be `Then | Else` (i.e. `boolean` by default),
9
+ * instead of distinctive `Then` (`true`) or `Else` (`false`).
10
+ *
11
+ * This is the correct behavior.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * CanAssign<number | string, number> // boolean
16
+ * ```
17
+ *
18
+ * We are checking can `A` assign to `B`.
19
+ * Since `A` is `number | string`,
20
+ * `A` can assign to `B` when `A` is number` (true), and
21
+ * `A` cannot assign to `B` when `A` is string` (false).
22
+ * So the result is `true | false = boolean`.
23
+ *
24
+ * If you want to make sure all branches are assignable,
25
+ * use `StrictCanAssign<A, B>`.
6
26
  */
7
27
  export type CanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true
8
28
  ? Record<string, unknown> extends B
@@ -16,6 +36,32 @@ export type CanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extend
16
36
  ? Then
17
37
  : Else
18
38
 
39
+ /**
40
+ * Can `A` strictly assign to `B`.
41
+ *
42
+ * All branches in an union `A` are assignable to `B`.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * StrictCanAssign<number | string, number> // false
47
+ * StrictCanAssign<number | string, number | string> // true
48
+ * ```
49
+ */
50
+ export type StrictCanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true
51
+ ? Record<string, unknown> extends B
52
+ ? Then
53
+ : Else
54
+ : boolean extends A
55
+ ? boolean extends B
56
+ ? Then
57
+ : Else
58
+ : [A] extends [B]
59
+ ? Then
60
+ : Else
61
+
62
+ /**
63
+ * @deprecated use `CanAssign` instead
64
+ */
19
65
  export type IsAssign<A, B, Then = true, Else = false> = CanAssign<A, B, Then, Else>
20
66
 
21
67
  export function canAssign<T>(canAssign: false): <S>(subject: NotExtendable<S, T>) => true
@@ -1,4 +1,4 @@
1
- export type Extendable<A, B> = A extends B ? A : never
2
- export type NotExtendable<A, B> = A extends B ? never : A
1
+ export type Extendable<A, B, Then = A, Else = never> = A extends B ? Then : Else
2
+ export type NotExtendable<A, B, Then = A, Else = never> = A extends B ? Else : Then
3
3
  export type IsExtend<A, B, Then = true, Else = false> = A extends B ? Then : Else
4
4
  export type IsNotExtend<A, B, Then = true, Else = false> = A extends B ? Else : Then
@@ -2,7 +2,6 @@ export * from './CanAssign.js'
2
2
  export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js'
3
3
  export type { If } from './If.js'
4
4
  export type { IsEmptyObject } from './IsEmptyObject.js'
5
- export * from './isType.js'
6
5
  export type { And, Not, Or, Xor } from './logical.js'
7
6
 
8
7
  export type IsLiteral<T extends number | string, Then = true, Else = false> = number extends T