type-plus 4.8.2 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (734) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -18
  3. package/cjs/ComposableTypes.d.ts +1 -0
  4. package/cjs/ComposableTypes.d.ts.map +1 -0
  5. package/cjs/JSONTypes.d.ts +1 -0
  6. package/cjs/JSONTypes.d.ts.map +1 -0
  7. package/cjs/JSONTypes.js.map +1 -1
  8. package/cjs/PrimitiveTypes.d.ts +1 -0
  9. package/cjs/PrimitiveTypes.d.ts.map +1 -0
  10. package/cjs/UnionKeys.d.ts +1 -0
  11. package/cjs/UnionKeys.d.ts.map +1 -0
  12. package/cjs/array/CommonPropKeys.d.ts +2 -1
  13. package/cjs/array/CommonPropKeys.d.ts.map +1 -0
  14. package/cjs/array/Concat.d.ts +1 -0
  15. package/cjs/array/Concat.d.ts.map +1 -0
  16. package/cjs/array/CreateTuple.d.ts +2 -1
  17. package/cjs/array/CreateTuple.d.ts.map +1 -0
  18. package/cjs/array/Filter.d.ts +1 -0
  19. package/cjs/array/Filter.d.ts.map +1 -0
  20. package/cjs/array/FindFirst.d.ts +1 -0
  21. package/cjs/array/FindFirst.d.ts.map +1 -0
  22. package/cjs/array/FindLast.d.ts +1 -0
  23. package/cjs/array/FindLast.d.ts.map +1 -0
  24. package/cjs/array/Head.d.ts +1 -0
  25. package/cjs/array/Head.d.ts.map +1 -0
  26. package/cjs/array/IntersectOfProps.d.ts +3 -2
  27. package/cjs/array/IntersectOfProps.d.ts.map +1 -0
  28. package/cjs/array/IsArray.d.ts +1 -0
  29. package/cjs/array/IsArray.d.ts.map +1 -0
  30. package/cjs/array/Last.d.ts +1 -0
  31. package/cjs/array/Last.d.ts.map +1 -0
  32. package/cjs/array/PadLeft.d.ts +4 -3
  33. package/cjs/array/PadLeft.d.ts.map +1 -0
  34. package/cjs/array/Reverse.d.ts +1 -0
  35. package/cjs/array/Reverse.d.ts.map +1 -0
  36. package/cjs/array/Some.d.ts +4 -3
  37. package/cjs/array/Some.d.ts.map +1 -0
  38. package/cjs/array/Tail.d.ts +2 -1
  39. package/cjs/array/Tail.d.ts.map +1 -0
  40. package/cjs/array/UnionOfProps.d.ts +3 -2
  41. package/cjs/array/UnionOfProps.d.ts.map +1 -0
  42. package/cjs/array/UnionOfValues.d.ts +1 -0
  43. package/cjs/array/UnionOfValues.d.ts.map +1 -0
  44. package/cjs/array/drop.d.ts +3 -2
  45. package/cjs/array/drop.d.ts.map +1 -0
  46. package/cjs/array/drop.js.map +1 -1
  47. package/cjs/array/index.d.ts +20 -19
  48. package/cjs/array/index.d.ts.map +1 -0
  49. package/cjs/array/index.js +3 -3
  50. package/cjs/array/index.js.map +1 -1
  51. package/cjs/array/literalArray.d.ts +2 -1
  52. package/cjs/array/literalArray.d.ts.map +1 -0
  53. package/cjs/array/reduceWhile.d.ts +1 -0
  54. package/cjs/array/reduceWhile.d.ts.map +1 -0
  55. package/cjs/assertion/assertType.d.ts +3 -2
  56. package/cjs/assertion/assertType.d.ts.map +1 -0
  57. package/cjs/assertion/assertType.js +3 -3
  58. package/cjs/assertion/assertType.js.map +1 -1
  59. package/cjs/assertion/index.d.ts +2 -1
  60. package/cjs/assertion/index.d.ts.map +1 -0
  61. package/cjs/assertion/index.js +1 -1
  62. package/cjs/assertion/index.js.map +1 -1
  63. package/cjs/class/AnyConstructor.d.ts +1 -0
  64. package/cjs/class/AnyConstructor.d.ts.map +1 -0
  65. package/cjs/class/index.d.ts +3 -2
  66. package/cjs/class/index.d.ts.map +1 -0
  67. package/cjs/class/index.js +1 -1
  68. package/cjs/class/index.js.map +1 -1
  69. package/cjs/class/isConstructor.d.ts +2 -1
  70. package/cjs/class/isConstructor.d.ts.map +1 -0
  71. package/cjs/function/AnyFunction.d.ts +1 -0
  72. package/cjs/function/AnyFunction.d.ts.map +1 -0
  73. package/cjs/function/index.d.ts +2 -1
  74. package/cjs/function/index.d.ts.map +1 -0
  75. package/cjs/functional/ChainFn.d.ts +1 -0
  76. package/cjs/functional/ChainFn.d.ts.map +1 -0
  77. package/cjs/functional/compose.d.ts +3 -2
  78. package/cjs/functional/compose.d.ts.map +1 -0
  79. package/cjs/functional/compose.js.map +1 -1
  80. package/cjs/functional/index.d.ts +3 -2
  81. package/cjs/functional/index.d.ts.map +1 -0
  82. package/cjs/functional/index.js +1 -1
  83. package/cjs/functional/index.js.map +1 -1
  84. package/cjs/index.d.ts +18 -17
  85. package/cjs/index.d.ts.map +1 -0
  86. package/cjs/index.js +14 -14
  87. package/cjs/index.js.map +1 -1
  88. package/cjs/math/Abs.d.ts +2 -1
  89. package/cjs/math/Abs.d.ts.map +1 -0
  90. package/cjs/math/Add.d.ts +7 -6
  91. package/cjs/math/Add.d.ts.map +1 -0
  92. package/cjs/math/Digit.d.ts +7 -4
  93. package/cjs/math/Digit.d.ts.map +1 -0
  94. package/cjs/math/GreaterThan.d.ts +10 -9
  95. package/cjs/math/GreaterThan.d.ts.map +1 -0
  96. package/cjs/math/IsPositive.d.ts +1 -0
  97. package/cjs/math/IsPositive.d.ts.map +1 -0
  98. package/cjs/math/IsWhole.d.ts +1 -0
  99. package/cjs/math/IsWhole.d.ts.map +1 -0
  100. package/cjs/math/Max.d.ts +4 -10
  101. package/cjs/math/Max.d.ts.map +1 -0
  102. package/cjs/math/Subtract.d.ts +7 -6
  103. package/cjs/math/Subtract.d.ts.map +1 -0
  104. package/cjs/math/index.d.ts +9 -8
  105. package/cjs/math/index.d.ts.map +1 -0
  106. package/cjs/nodejs/index.d.ts +2 -1
  107. package/cjs/nodejs/index.d.ts.map +1 -0
  108. package/cjs/nodejs/index.js +1 -1
  109. package/cjs/nodejs/index.js.map +1 -1
  110. package/cjs/nodejs/isNodeError.d.ts +1 -0
  111. package/cjs/nodejs/isNodeError.d.ts.map +1 -0
  112. package/cjs/nominal-types/Brand.d.ts +3 -2
  113. package/cjs/nominal-types/Brand.d.ts.map +1 -0
  114. package/cjs/nominal-types/Brand.js +2 -2
  115. package/cjs/nominal-types/Brand.js.map +1 -1
  116. package/cjs/nominal-types/Flavor.d.ts +3 -2
  117. package/cjs/nominal-types/Flavor.d.ts.map +1 -0
  118. package/cjs/nominal-types/Flavor.js +2 -2
  119. package/cjs/nominal-types/Flavor.js.map +1 -1
  120. package/cjs/nominal-types/index.d.ts +4 -3
  121. package/cjs/nominal-types/index.d.ts.map +1 -0
  122. package/cjs/nominal-types/index.js +3 -3
  123. package/cjs/nominal-types/index.js.map +1 -1
  124. package/cjs/nominal-types/nominalMatch.d.ts +3 -2
  125. package/cjs/nominal-types/nominalMatch.d.ts.map +1 -0
  126. package/cjs/nominal-types/nominalMatch.js +2 -2
  127. package/cjs/nominal-types/nominalMatch.js.map +1 -1
  128. package/cjs/nominal-types/types.d.ts +1 -0
  129. package/cjs/nominal-types/types.d.ts.map +1 -0
  130. package/cjs/object/ANotB.d.ts +5 -4
  131. package/cjs/object/ANotB.d.ts.map +1 -0
  132. package/cjs/object/AnyRecord.d.ts +1 -0
  133. package/cjs/object/AnyRecord.d.ts.map +1 -0
  134. package/cjs/object/ExcludePropType.d.ts +1 -0
  135. package/cjs/object/ExcludePropType.d.ts.map +1 -0
  136. package/cjs/object/IsDisjoint.d.ts +4 -3
  137. package/cjs/object/IsDisjoint.d.ts.map +1 -0
  138. package/cjs/object/IsRecord.d.ts +1 -0
  139. package/cjs/object/IsRecord.d.ts.map +1 -0
  140. package/cjs/object/KeyTypes.d.ts +1 -0
  141. package/cjs/object/KeyTypes.d.ts.map +1 -0
  142. package/cjs/object/KeyofOptional.d.ts +1 -0
  143. package/cjs/object/KeyofOptional.d.ts.map +1 -0
  144. package/cjs/object/KeysWithDiffType.d.ts +4 -3
  145. package/cjs/object/KeysWithDiffType.d.ts.map +1 -0
  146. package/cjs/object/KnownKeys.d.ts +2 -1
  147. package/cjs/object/KnownKeys.d.ts.map +1 -0
  148. package/cjs/object/OptionalKeys.d.ts +2 -1
  149. package/cjs/object/OptionalKeys.d.ts.map +1 -0
  150. package/cjs/object/Partial.d.ts +4 -3
  151. package/cjs/object/Partial.d.ts.map +1 -0
  152. package/cjs/object/RecursiveIntersect.d.ts +2 -1
  153. package/cjs/object/RecursiveIntersect.d.ts.map +1 -0
  154. package/cjs/object/RecursivePartial.d.ts +2 -1
  155. package/cjs/object/RecursivePartial.d.ts.map +1 -0
  156. package/cjs/object/RecursiveRequired.d.ts +2 -1
  157. package/cjs/object/RecursiveRequired.d.ts.map +1 -0
  158. package/cjs/object/Required.d.ts +1 -0
  159. package/cjs/object/Required.d.ts.map +1 -0
  160. package/cjs/object/RequiredKeys.d.ts +3 -2
  161. package/cjs/object/RequiredKeys.d.ts.map +1 -0
  162. package/cjs/object/SpreadRecord.d.ts +2 -1
  163. package/cjs/object/SpreadRecord.d.ts.map +1 -0
  164. package/cjs/object/ValueOf.d.ts +1 -0
  165. package/cjs/object/ValueOf.d.ts.map +1 -0
  166. package/cjs/object/everyKey.d.ts +2 -1
  167. package/cjs/object/everyKey.d.ts.map +1 -0
  168. package/cjs/object/facade.d.ts +2 -1
  169. package/cjs/object/facade.d.ts.map +1 -0
  170. package/cjs/object/filterKey.d.ts +2 -1
  171. package/cjs/object/filterKey.d.ts.map +1 -0
  172. package/cjs/object/findKey.d.ts +2 -1
  173. package/cjs/object/findKey.d.ts.map +1 -0
  174. package/cjs/object/forEachKey.d.ts +2 -1
  175. package/cjs/object/forEachKey.d.ts.map +1 -0
  176. package/cjs/object/getField.d.ts +2 -1
  177. package/cjs/object/getField.d.ts.map +1 -0
  178. package/cjs/object/hasKey.d.ts +2 -1
  179. package/cjs/object/hasKey.d.ts.map +1 -0
  180. package/cjs/object/hasProperty.d.ts +2 -1
  181. package/cjs/object/hasProperty.d.ts.map +1 -0
  182. package/cjs/object/index.d.ts +37 -36
  183. package/cjs/object/index.d.ts.map +1 -0
  184. package/cjs/object/index.js +18 -18
  185. package/cjs/object/index.js.map +1 -1
  186. package/cjs/object/mapKey.d.ts +2 -1
  187. package/cjs/object/mapKey.d.ts.map +1 -0
  188. package/cjs/object/mapProperties.d.ts +3 -2
  189. package/cjs/object/mapProperties.d.ts.map +1 -0
  190. package/cjs/object/mapProperties.js +2 -2
  191. package/cjs/object/mapProperties.js.map +1 -1
  192. package/cjs/object/omit.d.ts +4 -3
  193. package/cjs/object/omit.d.ts.map +1 -0
  194. package/cjs/object/omit.js +2 -2
  195. package/cjs/object/omit.js.map +1 -1
  196. package/cjs/object/pick.d.ts +3 -2
  197. package/cjs/object/pick.d.ts.map +1 -0
  198. package/cjs/object/pick.js +2 -2
  199. package/cjs/object/pick.js.map +1 -1
  200. package/cjs/object/record.d.ts +3 -2
  201. package/cjs/object/record.d.ts.map +1 -0
  202. package/cjs/object/record.js +1 -1
  203. package/cjs/object/record.js.map +1 -1
  204. package/cjs/object/reduceKey.d.ts +2 -1
  205. package/cjs/object/reduceKey.d.ts.map +1 -0
  206. package/cjs/object/replaceProperty.d.ts +2 -1
  207. package/cjs/object/replaceProperty.d.ts.map +1 -0
  208. package/cjs/object/someKey.d.ts +2 -1
  209. package/cjs/object/someKey.d.ts.map +1 -0
  210. package/cjs/object/split.d.ts +3 -2
  211. package/cjs/object/split.d.ts.map +1 -0
  212. package/cjs/object/split.js +3 -3
  213. package/cjs/object/split.js.map +1 -1
  214. package/cjs/object/typeOverrideIncompatible.d.ts +2 -1
  215. package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -0
  216. package/cjs/predicates/CanAssign.d.ts +3 -2
  217. package/cjs/predicates/CanAssign.d.ts.map +1 -0
  218. package/cjs/predicates/Equal.d.ts +1 -0
  219. package/cjs/predicates/Equal.d.ts.map +1 -0
  220. package/cjs/predicates/Extends.d.ts +1 -0
  221. package/cjs/predicates/Extends.d.ts.map +1 -0
  222. package/cjs/predicates/If.d.ts +1 -0
  223. package/cjs/predicates/If.d.ts.map +1 -0
  224. package/cjs/predicates/IsEmptyObject.d.ts +1 -0
  225. package/cjs/predicates/IsEmptyObject.d.ts.map +1 -0
  226. package/cjs/predicates/index.d.ts +9 -8
  227. package/cjs/predicates/index.d.ts.map +1 -0
  228. package/cjs/predicates/index.js +2 -2
  229. package/cjs/predicates/index.js.map +1 -1
  230. package/cjs/predicates/isType.d.ts +3 -2
  231. package/cjs/predicates/isType.d.ts.map +1 -0
  232. package/cjs/predicates/isType.js +2 -2
  233. package/cjs/predicates/isType.js.map +1 -1
  234. package/cjs/predicates/logical.d.ts +1 -0
  235. package/cjs/predicates/logical.d.ts.map +1 -0
  236. package/cjs/promise/PromiseValue.d.ts +1 -0
  237. package/cjs/promise/PromiseValue.d.ts.map +1 -0
  238. package/cjs/promise/PromiseValueMerge.d.ts +2 -1
  239. package/cjs/promise/PromiseValueMerge.d.ts.map +1 -0
  240. package/cjs/promise/index.d.ts +5 -4
  241. package/cjs/promise/index.d.ts.map +1 -0
  242. package/cjs/promise/index.js +2 -2
  243. package/cjs/promise/index.js.map +1 -1
  244. package/cjs/promise/isPromise.d.ts +1 -0
  245. package/cjs/promise/isPromise.d.ts.map +1 -0
  246. package/cjs/promise/mapSeries.d.ts +1 -0
  247. package/cjs/promise/mapSeries.d.ts.map +1 -0
  248. package/cjs/testing/index.d.ts +2 -1
  249. package/cjs/testing/index.d.ts.map +1 -0
  250. package/cjs/testing/index.js +1 -1
  251. package/cjs/testing/index.js.map +1 -1
  252. package/cjs/testing/stub.d.ts +3 -2
  253. package/cjs/testing/stub.d.ts.map +1 -0
  254. package/cjs/utils/NonNull.d.ts +1 -0
  255. package/cjs/utils/NonNull.d.ts.map +1 -0
  256. package/cjs/utils/NonUndefined.d.ts +1 -0
  257. package/cjs/utils/NonUndefined.d.ts.map +1 -0
  258. package/cjs/utils/Widen.d.ts +1 -0
  259. package/cjs/utils/Widen.d.ts.map +1 -0
  260. package/cjs/utils/as.d.ts +1 -0
  261. package/cjs/utils/as.d.ts.map +1 -0
  262. package/cjs/utils/index.d.ts +5 -4
  263. package/cjs/utils/index.d.ts.map +1 -0
  264. package/cjs/utils/index.js +1 -1
  265. package/cjs/utils/index.js.map +1 -1
  266. package/esm/ComposableTypes.d.ts +3 -0
  267. package/esm/ComposableTypes.d.ts.map +1 -0
  268. package/esm/JSONTypes.d.ts +12 -0
  269. package/esm/JSONTypes.d.ts.map +1 -0
  270. package/esm/JSONTypes.js.map +1 -1
  271. package/esm/PrimitiveTypes.d.ts +2 -0
  272. package/esm/PrimitiveTypes.d.ts.map +1 -0
  273. package/esm/UnionKeys.d.ts +2 -0
  274. package/esm/UnionKeys.d.ts.map +1 -0
  275. package/esm/array/CommonPropKeys.d.ts +4 -0
  276. package/esm/array/CommonPropKeys.d.ts.map +1 -0
  277. package/esm/array/Concat.d.ts +2 -0
  278. package/esm/array/Concat.d.ts.map +1 -0
  279. package/esm/array/CreateTuple.d.ts +3 -0
  280. package/esm/array/CreateTuple.d.ts.map +1 -0
  281. package/esm/array/Filter.d.ts +3 -0
  282. package/esm/array/Filter.d.ts.map +1 -0
  283. package/esm/array/FindFirst.d.ts +3 -0
  284. package/esm/array/FindFirst.d.ts.map +1 -0
  285. package/esm/array/FindLast.d.ts +2 -0
  286. package/esm/array/FindLast.d.ts.map +1 -0
  287. package/esm/array/Head.d.ts +2 -0
  288. package/esm/array/Head.d.ts.map +1 -0
  289. package/esm/array/IntersectOfProps.d.ts +5 -0
  290. package/esm/array/IntersectOfProps.d.ts.map +1 -0
  291. package/esm/array/IsArray.d.ts +2 -0
  292. package/esm/array/IsArray.d.ts.map +1 -0
  293. package/esm/array/Last.d.ts +2 -0
  294. package/esm/array/Last.d.ts.map +1 -0
  295. package/esm/array/PadLeft.d.ts +5 -0
  296. package/esm/array/PadLeft.d.ts.map +1 -0
  297. package/esm/array/Reverse.d.ts +2 -0
  298. package/esm/array/Reverse.d.ts.map +1 -0
  299. package/esm/array/Some.d.ts +8 -0
  300. package/esm/array/Some.d.ts.map +1 -0
  301. package/esm/array/Tail.d.ts +3 -0
  302. package/esm/array/Tail.d.ts.map +1 -0
  303. package/esm/array/UnionOfProps.d.ts +5 -0
  304. package/esm/array/UnionOfProps.d.ts.map +1 -0
  305. package/esm/array/UnionOfValues.d.ts +3 -0
  306. package/esm/array/UnionOfValues.d.ts.map +1 -0
  307. package/esm/array/drop.d.ts +13 -0
  308. package/esm/array/drop.d.ts.map +1 -0
  309. package/esm/array/drop.js.map +1 -1
  310. package/esm/array/index.d.ts +20 -0
  311. package/esm/array/index.d.ts.map +1 -0
  312. package/esm/array/index.js +3 -3
  313. package/esm/array/index.js.map +1 -1
  314. package/esm/array/literalArray.d.ts +3 -0
  315. package/esm/array/literalArray.d.ts.map +1 -0
  316. package/esm/array/reduceWhile.d.ts +2 -0
  317. package/esm/array/reduceWhile.d.ts.map +1 -0
  318. package/esm/assertion/assertType.d.ts +29 -0
  319. package/esm/assertion/assertType.d.ts.map +1 -0
  320. package/esm/assertion/assertType.js +1 -1
  321. package/esm/assertion/assertType.js.map +1 -1
  322. package/esm/assertion/index.d.ts +2 -0
  323. package/esm/assertion/index.d.ts.map +1 -0
  324. package/esm/assertion/index.js +1 -1
  325. package/esm/assertion/index.js.map +1 -1
  326. package/esm/class/AnyConstructor.d.ts +2 -0
  327. package/esm/class/AnyConstructor.d.ts.map +1 -0
  328. package/esm/class/index.d.ts +3 -0
  329. package/esm/class/index.d.ts.map +1 -0
  330. package/esm/class/index.js +1 -1
  331. package/esm/class/index.js.map +1 -1
  332. package/esm/class/isConstructor.d.ts +3 -0
  333. package/esm/class/isConstructor.d.ts.map +1 -0
  334. package/esm/function/AnyFunction.d.ts +2 -0
  335. package/esm/function/AnyFunction.d.ts.map +1 -0
  336. package/esm/function/index.d.ts +2 -0
  337. package/esm/function/index.d.ts.map +1 -0
  338. package/esm/functional/ChainFn.d.ts +3 -0
  339. package/esm/functional/ChainFn.d.ts.map +1 -0
  340. package/esm/functional/compose.d.ts +4 -0
  341. package/esm/functional/compose.d.ts.map +1 -0
  342. package/esm/functional/compose.js.map +1 -1
  343. package/esm/functional/index.d.ts +3 -0
  344. package/esm/functional/index.d.ts.map +1 -0
  345. package/esm/functional/index.js +1 -1
  346. package/esm/functional/index.js.map +1 -1
  347. package/esm/index.d.ts +19 -0
  348. package/esm/index.d.ts.map +1 -0
  349. package/esm/index.js +14 -14
  350. package/esm/index.js.map +1 -1
  351. package/esm/math/Abs.d.ts +3 -0
  352. package/esm/math/Abs.d.ts.map +1 -0
  353. package/esm/math/Add.d.ts +16 -0
  354. package/esm/math/Add.d.ts.map +1 -0
  355. package/esm/math/Digit.d.ts +97 -0
  356. package/esm/math/Digit.d.ts.map +1 -0
  357. package/esm/math/GreaterThan.d.ts +12 -0
  358. package/esm/math/GreaterThan.d.ts.map +1 -0
  359. package/esm/math/IsPositive.d.ts +2 -0
  360. package/esm/math/IsPositive.d.ts.map +1 -0
  361. package/esm/math/IsWhole.d.ts +2 -0
  362. package/esm/math/IsWhole.d.ts.map +1 -0
  363. package/esm/math/Max.d.ts +4 -0
  364. package/esm/math/Max.d.ts.map +1 -0
  365. package/esm/math/Subtract.d.ts +13 -0
  366. package/esm/math/Subtract.d.ts.map +1 -0
  367. package/esm/math/index.d.ts +9 -0
  368. package/esm/math/index.d.ts.map +1 -0
  369. package/esm/nodejs/index.d.ts +2 -0
  370. package/esm/nodejs/index.d.ts.map +1 -0
  371. package/esm/nodejs/index.js +1 -1
  372. package/esm/nodejs/index.js.map +1 -1
  373. package/esm/nodejs/isNodeError.d.ts +26 -0
  374. package/esm/nodejs/isNodeError.d.ts.map +1 -0
  375. package/esm/nominal-types/Brand.d.ts +11 -0
  376. package/esm/nominal-types/Brand.d.ts.map +1 -0
  377. package/esm/nominal-types/Brand.js +1 -1
  378. package/esm/nominal-types/Brand.js.map +1 -1
  379. package/esm/nominal-types/Flavor.d.ts +8 -0
  380. package/esm/nominal-types/Flavor.d.ts.map +1 -0
  381. package/esm/nominal-types/Flavor.js +1 -1
  382. package/esm/nominal-types/Flavor.js.map +1 -1
  383. package/esm/nominal-types/index.d.ts +4 -0
  384. package/esm/nominal-types/index.d.ts.map +1 -0
  385. package/esm/nominal-types/index.js +3 -3
  386. package/esm/nominal-types/index.js.map +1 -1
  387. package/esm/nominal-types/nominalMatch.d.ts +5 -0
  388. package/esm/nominal-types/nominalMatch.d.ts.map +1 -0
  389. package/esm/nominal-types/nominalMatch.js +1 -1
  390. package/esm/nominal-types/nominalMatch.js.map +1 -1
  391. package/esm/nominal-types/types.d.ts +3 -0
  392. package/esm/nominal-types/types.d.ts.map +1 -0
  393. package/esm/object/ANotB.d.ts +14 -0
  394. package/esm/object/ANotB.d.ts.map +1 -0
  395. package/esm/object/AnyRecord.d.ts +2 -0
  396. package/esm/object/AnyRecord.d.ts.map +1 -0
  397. package/esm/object/ExcludePropType.d.ts +4 -0
  398. package/esm/object/ExcludePropType.d.ts.map +1 -0
  399. package/esm/object/IsDisjoint.d.ts +5 -0
  400. package/esm/object/IsDisjoint.d.ts.map +1 -0
  401. package/esm/object/IsRecord.d.ts +2 -0
  402. package/esm/object/IsRecord.d.ts.map +1 -0
  403. package/esm/object/KeyTypes.d.ts +2 -0
  404. package/esm/object/KeyTypes.d.ts.map +1 -0
  405. package/esm/object/KeyofOptional.d.ts +3 -0
  406. package/esm/object/KeyofOptional.d.ts.map +1 -0
  407. package/esm/object/KeysWithDiffType.d.ts +7 -0
  408. package/esm/object/KeysWithDiffType.d.ts.map +1 -0
  409. package/esm/object/KnownKeys.d.ts +7 -0
  410. package/esm/object/KnownKeys.d.ts.map +1 -0
  411. package/esm/object/OptionalKeys.d.ts +8 -0
  412. package/esm/object/OptionalKeys.d.ts.map +1 -0
  413. package/esm/object/Partial.d.ts +7 -0
  414. package/esm/object/Partial.d.ts.map +1 -0
  415. package/esm/object/RecursiveIntersect.d.ts +5 -0
  416. package/esm/object/RecursiveIntersect.d.ts.map +1 -0
  417. package/esm/object/RecursivePartial.d.ts +5 -0
  418. package/esm/object/RecursivePartial.d.ts.map +1 -0
  419. package/esm/object/RecursiveRequired.d.ts +5 -0
  420. package/esm/object/RecursiveRequired.d.ts.map +1 -0
  421. package/esm/object/Required.d.ts +3 -0
  422. package/esm/object/Required.d.ts.map +1 -0
  423. package/esm/object/RequiredKeys.d.ts +7 -0
  424. package/esm/object/RequiredKeys.d.ts.map +1 -0
  425. package/esm/object/SpreadRecord.d.ts +3 -0
  426. package/esm/object/SpreadRecord.d.ts.map +1 -0
  427. package/esm/object/ValueOf.d.ts +2 -0
  428. package/esm/object/ValueOf.d.ts.map +1 -0
  429. package/esm/object/everyKey.d.ts +3 -0
  430. package/esm/object/everyKey.d.ts.map +1 -0
  431. package/esm/object/facade.d.ts +14 -0
  432. package/esm/object/facade.d.ts.map +1 -0
  433. package/esm/object/filterKey.d.ts +3 -0
  434. package/esm/object/filterKey.d.ts.map +1 -0
  435. package/esm/object/findKey.d.ts +3 -0
  436. package/esm/object/findKey.d.ts.map +1 -0
  437. package/esm/object/forEachKey.d.ts +3 -0
  438. package/esm/object/forEachKey.d.ts.map +1 -0
  439. package/esm/object/getField.d.ts +4 -0
  440. package/esm/object/getField.d.ts.map +1 -0
  441. package/esm/object/hasKey.d.ts +4 -0
  442. package/esm/object/hasKey.d.ts.map +1 -0
  443. package/esm/object/hasProperty.d.ts +3 -0
  444. package/esm/object/hasProperty.d.ts.map +1 -0
  445. package/esm/object/index.d.ts +37 -0
  446. package/esm/object/index.d.ts.map +1 -0
  447. package/esm/object/index.js +18 -18
  448. package/esm/object/index.js.map +1 -1
  449. package/esm/object/mapKey.d.ts +3 -0
  450. package/esm/object/mapKey.d.ts.map +1 -0
  451. package/esm/object/mapProperties.d.ts +6 -0
  452. package/esm/object/mapProperties.d.ts.map +1 -0
  453. package/esm/object/mapProperties.js +1 -1
  454. package/esm/object/mapProperties.js.map +1 -1
  455. package/esm/object/omit.d.ts +18 -0
  456. package/esm/object/omit.d.ts.map +1 -0
  457. package/esm/object/omit.js +1 -1
  458. package/esm/object/omit.js.map +1 -1
  459. package/esm/object/pick.d.ts +21 -0
  460. package/esm/object/pick.d.ts.map +1 -0
  461. package/esm/object/pick.js +1 -1
  462. package/esm/object/pick.js.map +1 -1
  463. package/esm/object/record.d.ts +4 -0
  464. package/esm/object/record.d.ts.map +1 -0
  465. package/esm/object/record.js +1 -1
  466. package/esm/object/record.js.map +1 -1
  467. package/esm/object/reduceKey.d.ts +4 -0
  468. package/esm/object/reduceKey.d.ts.map +1 -0
  469. package/esm/object/replaceProperty.d.ts +6 -0
  470. package/esm/object/replaceProperty.d.ts.map +1 -0
  471. package/esm/object/someKey.d.ts +3 -0
  472. package/esm/object/someKey.d.ts.map +1 -0
  473. package/esm/object/split.d.ts +82 -0
  474. package/esm/object/split.d.ts.map +1 -0
  475. package/esm/object/split.js +1 -1
  476. package/esm/object/split.js.map +1 -1
  477. package/esm/object/typeOverrideIncompatible.d.ts +3 -0
  478. package/esm/object/typeOverrideIncompatible.d.ts.map +1 -0
  479. package/esm/predicates/CanAssign.d.ts +7 -0
  480. package/esm/predicates/CanAssign.d.ts.map +1 -0
  481. package/esm/predicates/Equal.d.ts +5 -0
  482. package/esm/predicates/Equal.d.ts.map +1 -0
  483. package/esm/predicates/Extends.d.ts +5 -0
  484. package/esm/predicates/Extends.d.ts.map +1 -0
  485. package/esm/predicates/If.d.ts +2 -0
  486. package/esm/predicates/If.d.ts.map +1 -0
  487. package/esm/predicates/IsEmptyObject.d.ts +2 -0
  488. package/esm/predicates/IsEmptyObject.d.ts.map +1 -0
  489. package/esm/predicates/index.d.ts +12 -0
  490. package/esm/predicates/index.d.ts.map +1 -0
  491. package/esm/predicates/index.js +2 -2
  492. package/esm/predicates/index.js.map +1 -1
  493. package/esm/predicates/isType.d.ts +11 -0
  494. package/esm/predicates/isType.d.ts.map +1 -0
  495. package/esm/predicates/isType.js +1 -1
  496. package/esm/predicates/isType.js.map +1 -1
  497. package/esm/predicates/logical.d.ts +5 -0
  498. package/esm/predicates/logical.d.ts.map +1 -0
  499. package/esm/promise/PromiseValue.d.ts +2 -0
  500. package/esm/promise/PromiseValue.d.ts.map +1 -0
  501. package/esm/promise/PromiseValueMerge.d.ts +3 -0
  502. package/esm/promise/PromiseValueMerge.d.ts.map +1 -0
  503. package/esm/promise/index.d.ts +5 -0
  504. package/esm/promise/index.d.ts.map +1 -0
  505. package/esm/promise/index.js +2 -2
  506. package/esm/promise/index.js.map +1 -1
  507. package/esm/promise/isPromise.d.ts +2 -0
  508. package/esm/promise/isPromise.d.ts.map +1 -0
  509. package/esm/promise/mapSeries.d.ts +2 -0
  510. package/esm/promise/mapSeries.d.ts.map +1 -0
  511. package/esm/testing/index.d.ts +2 -0
  512. package/esm/testing/index.d.ts.map +1 -0
  513. package/esm/testing/index.js +1 -1
  514. package/esm/testing/index.js.map +1 -1
  515. package/esm/testing/stub.d.ts +10 -0
  516. package/esm/testing/stub.d.ts.map +1 -0
  517. package/esm/utils/NonNull.d.ts +2 -0
  518. package/esm/utils/NonNull.d.ts.map +1 -0
  519. package/esm/utils/NonUndefined.d.ts +2 -0
  520. package/esm/utils/NonUndefined.d.ts.map +1 -0
  521. package/esm/utils/Widen.d.ts +2 -0
  522. package/esm/utils/Widen.d.ts.map +1 -0
  523. package/esm/utils/as.d.ts +7 -0
  524. package/esm/utils/as.d.ts.map +1 -0
  525. package/esm/utils/index.d.ts +5 -0
  526. package/esm/utils/index.d.ts.map +1 -0
  527. package/esm/utils/index.js +1 -1
  528. package/esm/utils/index.js.map +1 -1
  529. package/package.json +47 -42
  530. package/ts/JSONTypes.ts +17 -18
  531. package/ts/array/CommonPropKeys.ts +18 -18
  532. package/ts/array/CreateTuple.ts +1 -1
  533. package/ts/array/IntersectOfProps.ts +20 -20
  534. package/ts/array/PadLeft.ts +3 -3
  535. package/ts/array/Some.ts +3 -3
  536. package/ts/array/Tail.ts +1 -1
  537. package/ts/array/UnionOfProps.ts +18 -18
  538. package/ts/array/drop.ts +3 -3
  539. package/ts/array/index.ts +19 -19
  540. package/ts/array/literalArray.ts +1 -1
  541. package/ts/assertion/assertType.ts +105 -105
  542. package/ts/assertion/index.ts +1 -1
  543. package/ts/binary/_binary.ts +1 -1
  544. package/ts/binary/index.ts +2 -2
  545. package/ts/class/index.ts +2 -2
  546. package/ts/class/isConstructor.ts +1 -1
  547. package/ts/function/index.ts +1 -1
  548. package/ts/functional/Maybe.ts +19 -19
  549. package/ts/functional/compose.ts +4 -3
  550. package/ts/functional/index.ts +3 -3
  551. package/ts/index.ts +19 -19
  552. package/ts/math/Abs.ts +1 -1
  553. package/ts/math/Add.ts +6 -6
  554. package/ts/math/Digit.ts +6 -4
  555. package/ts/math/GreaterThan.ts +16 -17
  556. package/ts/math/Max.ts +6 -30
  557. package/ts/math/Subtract.ts +6 -6
  558. package/ts/math/index.ts +8 -8
  559. package/ts/nodejs/index.ts +1 -1
  560. package/ts/nominal-types/Brand.ts +2 -2
  561. package/ts/nominal-types/Flavor.ts +32 -32
  562. package/ts/nominal-types/index.ts +3 -3
  563. package/ts/nominal-types/nominalMatch.ts +3 -3
  564. package/ts/object/ANotB.ts +21 -21
  565. package/ts/object/IsDisjoint.ts +12 -12
  566. package/ts/object/KeysWithDiffType.ts +3 -3
  567. package/ts/object/KnownKeys.ts +1 -1
  568. package/ts/object/OptionalKeys.ts +1 -1
  569. package/ts/object/Partial.ts +3 -3
  570. package/ts/object/RecursiveIntersect.ts +1 -1
  571. package/ts/object/RecursivePartial.ts +1 -1
  572. package/ts/object/RecursiveRequired.ts +1 -1
  573. package/ts/object/RequiredKeys.ts +2 -2
  574. package/ts/object/SpreadRecord.ts +6 -6
  575. package/ts/object/everyKey.ts +1 -1
  576. package/ts/object/facade.ts +39 -39
  577. package/ts/object/filterKey.ts +1 -1
  578. package/ts/object/findKey.ts +1 -1
  579. package/ts/object/forEachKey.ts +1 -1
  580. package/ts/object/getField.ts +1 -1
  581. package/ts/object/hasKey.ts +7 -7
  582. package/ts/object/hasProperty.ts +1 -1
  583. package/ts/object/index.ts +36 -36
  584. package/ts/object/mapKey.ts +1 -1
  585. package/ts/object/mapProperties.ts +3 -3
  586. package/ts/object/omit.ts +36 -36
  587. package/ts/object/pick.ts +35 -35
  588. package/ts/object/record.ts +5 -4
  589. package/ts/object/reduceKey.ts +1 -1
  590. package/ts/object/replaceProperty.ts +1 -1
  591. package/ts/object/someKey.ts +1 -1
  592. package/ts/object/split.ts +5 -4
  593. package/ts/object/typeOverrideIncompatible.ts +10 -10
  594. package/ts/predicates/CanAssign.ts +2 -2
  595. package/ts/predicates/index.ts +8 -8
  596. package/ts/predicates/isType.ts +30 -30
  597. package/ts/promise/PromiseValueMerge.ts +1 -1
  598. package/ts/promise/index.ts +4 -4
  599. package/ts/testing/index.ts +1 -1
  600. package/ts/testing/stub.ts +2 -2
  601. package/ts/utils/index.ts +4 -4
  602. package/ts/ComposableTypes.spec.ts +0 -29
  603. package/ts/JSONTypes.spec.ts +0 -43
  604. package/ts/array/CommonPropKeys.spec.ts +0 -20
  605. package/ts/array/Concat.spec.ts +0 -21
  606. package/ts/array/CreateTuple.spec.ts +0 -46
  607. package/ts/array/DropFirst.spec.ts +0 -21
  608. package/ts/array/DropLast.spec.ts +0 -21
  609. package/ts/array/DropMatch.spec.ts +0 -234
  610. package/ts/array/Filter.spec.ts +0 -107
  611. package/ts/array/FindFirst.spec.ts +0 -27
  612. package/ts/array/FindLast.spec.ts +0 -27
  613. package/ts/array/Head.spec.ts +0 -21
  614. package/ts/array/IntersectOfProps.spec.ts +0 -14
  615. package/ts/array/Last.spec.ts +0 -32
  616. package/ts/array/PadLeft.spec.ts +0 -26
  617. package/ts/array/Reverse.spec.ts +0 -17
  618. package/ts/array/Some.spec.ts +0 -79
  619. package/ts/array/Tail.spec.ts +0 -32
  620. package/ts/array/UnionOfProps.spec.ts +0 -14
  621. package/ts/array/UnionOfValues.spec.ts +0 -11
  622. package/ts/array/literalArray.spec.ts +0 -7
  623. package/ts/array/reduceWhile.spec.ts +0 -27
  624. package/ts/assertion/assertType.spec.ts +0 -507
  625. package/ts/binary/index.spec.ts +0 -28
  626. package/ts/class/AnyConstructor.spec.ts +0 -13
  627. package/ts/class/isConstructor.spec.ts +0 -35
  628. package/ts/function/AnyFunction.spec.ts +0 -21
  629. package/ts/functional/ChainFn.spec.ts +0 -7
  630. package/ts/functional/Maybe.spec.ts +0 -42
  631. package/ts/functional/compose.spec.ts +0 -32
  632. package/ts/index.spec.ts +0 -7
  633. package/ts/math/Abs.spec.ts +0 -14
  634. package/ts/math/Add.spec.ts +0 -82
  635. package/ts/math/Digit.spec.ts +0 -184
  636. package/ts/math/GreaterThan.spec.ts +0 -43
  637. package/ts/math/IsPositive.spec.ts +0 -15
  638. package/ts/math/IsWhole.spec.ts +0 -19
  639. package/ts/math/Max.spec.ts +0 -35
  640. package/ts/math/Subtract.spec.ts +0 -40
  641. package/ts/nodejs/isNodeError.spec.ts +0 -11
  642. package/ts/nominal-types/Brand.spec.ts +0 -43
  643. package/ts/nominal-types/Flavor.spec.ts +0 -51
  644. package/ts/nominal-types/nominalMatch.spec.ts +0 -54
  645. package/ts/object/ANotB.spec.ts +0 -78
  646. package/ts/object/ExcludePropType.spec.ts +0 -13
  647. package/ts/object/IsDisjoint.spec.ts +0 -25
  648. package/ts/object/IsRecord.spec.ts +0 -22
  649. package/ts/object/KeyTypes.spec.ts +0 -9
  650. package/ts/object/KeyofOptional.spec.ts +0 -8
  651. package/ts/object/KeysWithDiffType.spec.ts +0 -21
  652. package/ts/object/KnownKeys.spec.ts +0 -39
  653. package/ts/object/OptionalKeys.spec.ts +0 -23
  654. package/ts/object/Partial.spec.ts +0 -49
  655. package/ts/object/RecursiveIntersect.spec.ts +0 -39
  656. package/ts/object/RecursiveRequired.spec.ts +0 -57
  657. package/ts/object/Required.spec.ts +0 -29
  658. package/ts/object/RequiredKeys.spec.ts +0 -24
  659. package/ts/object/SpreadRecord.spec.ts +0 -14
  660. package/ts/object/ValueOf.spec.ts +0 -36
  661. package/ts/object/everyKey.spec.ts +0 -11
  662. package/ts/object/facade.spec.ts +0 -22
  663. package/ts/object/filterKey.spec.ts +0 -8
  664. package/ts/object/findKey.spec.ts +0 -8
  665. package/ts/object/forEachKey.spec.ts +0 -9
  666. package/ts/object/getField.spec.ts +0 -21
  667. package/ts/object/hasKey.spec.ts +0 -29
  668. package/ts/object/hasProperty.spec.ts +0 -15
  669. package/ts/object/mapKey.spec.ts +0 -8
  670. package/ts/object/mapProperties.spec.ts +0 -27
  671. package/ts/object/omit.spec.ts +0 -104
  672. package/ts/object/pick.spec.ts +0 -66
  673. package/ts/object/record.spec.ts +0 -54
  674. package/ts/object/reduceKey.spec.ts +0 -18
  675. package/ts/object/replaceProperty.spec.ts +0 -16
  676. package/ts/object/run.ts +0 -0
  677. package/ts/object/someKey.spec.ts +0 -6
  678. package/ts/object/split.spec.ts +0 -119
  679. package/ts/object/typeOverrideIncompatible.spec.ts +0 -24
  680. package/ts/predicates/CanAssign.spec.ts +0 -57
  681. package/ts/predicates/Equal.spec.ts +0 -71
  682. package/ts/predicates/If.spec.ts +0 -14
  683. package/ts/predicates/IsEmptyObject.spec.ts +0 -15
  684. package/ts/predicates/index.spec.ts +0 -73
  685. package/ts/predicates/isType.spec.ts +0 -106
  686. package/ts/predicates/logical.spec.ts +0 -59
  687. package/ts/promise/PromiseValue.spec.ts +0 -6
  688. package/ts/promise/PromiseValueMerge.spec.ts +0 -7
  689. package/ts/promise/isPromise.spec.ts +0 -26
  690. package/ts/promise/mapSeries.spec.ts +0 -12
  691. package/ts/testing/stub.spec.ts +0 -58
  692. package/ts/type-checker/.eslintrc.json +0 -5
  693. package/ts/type-checker/AnyType.ts +0 -13
  694. package/ts/type-checker/Boolean.ts +0 -34
  695. package/ts/type-checker/Tuple.spec.ts +0 -15
  696. package/ts/type-checker/Tuple.ts +0 -14
  697. package/ts/type-checker/buildTypes.spec.ts +0 -28
  698. package/ts/type-checker/index.ts +0 -0
  699. package/ts/type-checker/typeChecker.spec.ts +0 -14
  700. package/ts/type-checker/typeChecker.ts +0 -52
  701. package/ts/type-checker/types.ts +0 -19
  702. package/ts/types/.eslintrc.json +0 -5
  703. package/ts/types/AllType.ts +0 -31
  704. package/ts/types/Any.ts +0 -7
  705. package/ts/types/Array.ts +0 -43
  706. package/ts/types/BigInt.ts +0 -36
  707. package/ts/types/Boolean.ts +0 -36
  708. package/ts/types/Generate.ts +0 -48
  709. package/ts/types/Null.ts +0 -14
  710. package/ts/types/Number.ts +0 -56
  711. package/ts/types/Object.ts +0 -53
  712. package/ts/types/Record.ts +0 -25
  713. package/ts/types/String.ts +0 -56
  714. package/ts/types/Symbol.ts +0 -19
  715. package/ts/types/Tuple.ts +0 -50
  716. package/ts/types/Undefined.ts +0 -8
  717. package/ts/types/Union.ts +0 -46
  718. package/ts/types/Unknown.ts +0 -9
  719. package/ts/types/analyze.spec.ts +0 -979
  720. package/ts/types/analyze.ts +0 -170
  721. package/ts/types/check.spec.ts +0 -12
  722. package/ts/types/check.ts +0 -26
  723. package/ts/types/conform.spec.ts +0 -7
  724. package/ts/types/conform.ts +0 -27
  725. package/ts/types/getPlainAnalysisReport.spec.ts +0 -354
  726. package/ts/types/getPlainAnalysisReport.ts +0 -115
  727. package/ts/types/index.ts +0 -28
  728. package/ts/types/optional.ts +0 -30
  729. package/ts/types/required.ts +0 -30
  730. package/ts/types/satisfy.accept.ts +0 -39
  731. package/ts/types/satisfy.spec.ts +0 -600
  732. package/ts/types/satisfy.ts +0 -27
  733. package/ts/types/types.ts +0 -10
  734. package/ts/utils/as.spec.ts +0 -45
@@ -1,507 +0,0 @@
1
- import a from 'assertron'
2
- import { AnyConstructor, AnyFunction, assertType, Equal } from '..'
3
-
4
- describe('assertType()', () => {
5
- test('input satisfies specified type', () => {
6
- const subject = { a: 1, b: 2 } as const
7
- assertType<{ a: 1 }>(subject)
8
- })
9
- test('Specify T in the validate function', () => {
10
- const s: unknown = false
11
- assertType(s, (s: boolean) => typeof s === 'boolean')
12
- assertType<boolean>(s)
13
- })
14
- test('Specify T at type declaration', () => {
15
- const s: unknown = false
16
- assertType<boolean>(s, s => typeof s === 'boolean')
17
- assertType<boolean>(s)
18
- })
19
- test('error message contains info from validator', () => {
20
- const s: unknown = 1
21
- a.throws(() => assertType(s, s => typeof s === 'boolean'), e => /subject fails to satisfy s => typeof s === 'boolean'/.test(e))
22
- })
23
- test('Class as validator', () => {
24
- const s: unknown = new Error()
25
- assertType(s, Error)
26
- assertType<Error>(s)
27
- })
28
- test('Class as validator fails', () => {
29
- class Foo { }
30
- const s: unknown = 1
31
- a.throws(
32
- () => assertType(s, Foo),
33
- (e: Error) => /subject fails to satisfy class Foo{}/.test(e.message)
34
- )
35
- })
36
- test('subject can be type any', () => {
37
- const s: any = false
38
- assertType<boolean>(s, s => typeof s === 'boolean')
39
- assertType<boolean>(s)
40
- })
41
- })
42
-
43
- describe('assertType.isUndefined()', () => {
44
- test('ensure the input type is undefined and nothing else', () => {
45
- assertType.isUndefined(undefined)
46
-
47
- // These fails
48
- // assertType.isUndefined(null)
49
- // assertType.isUndefined(1)
50
- // assertType.isUndefined(true)
51
- // assertType.isUndefined('a')
52
- // assertType.isUndefined([])
53
- // assertType.isUndefined({})
54
- // assertType.isUndefined(undefined as undefined | number)
55
- // assertType.isUndefined(undefined as unknown)
56
- })
57
- test('not undefined throws TypeError', () => {
58
- a.throws(() => assertType.isUndefined(1 as any), TypeError)
59
- })
60
- test('narrow any to undefined', () => {
61
- const x: any = undefined
62
- assertType.isUndefined(x)
63
- assertType.isTrue(true as Equal<undefined, typeof x>)
64
- })
65
- })
66
-
67
- describe('assertType.noUndefined()', () => {
68
- test('ensure the input type does not contain undefined', () => {
69
- assertType.noUndefined(null)
70
- assertType.noUndefined(1)
71
- assertType.noUndefined(true)
72
- assertType.noUndefined('a')
73
- assertType.noUndefined([])
74
- assertType.noUndefined({})
75
-
76
- // These fails
77
- // assertType.noUndefined(undefined)
78
- // assertType.noUndefined(1 as undefined | number)
79
- assertType.noUndefined(1 as unknown)
80
- })
81
- test('undefined throws TypeError', () => {
82
- a.throws(() => assertType.noUndefined(undefined as any), TypeError)
83
- })
84
- })
85
-
86
- describe('assertType.isNull()', () => {
87
- test('ensure the input type is null and nothing else', () => {
88
- assertType.isNull(null)
89
-
90
- a.throws(() => assertType.isNull(1 as any), TypeError)
91
- const x: any = null
92
- assertType.isNull(x)
93
- // `x` is narrowed to `null` here
94
- assertType.isNull(x)
95
-
96
- // These fails
97
- // assertType.isNull(undefined)
98
- // assertType.isNull(1)
99
- // assertType.isNull(true)
100
- // assertType.isNull('a')
101
- // assertType.isNull([])
102
- // assertType.isNull({})
103
- // assertType.isNull(null as null | undefined)
104
- // assertType.isNull(null as unknown)
105
- })
106
- test('not null throws TypeError', () => {
107
- a.throws(() => assertType.isNull(1 as any), TypeError)
108
- })
109
- test('narrow any to null', () => {
110
- const x: any = null
111
- assertType.isNull(x)
112
- assertType.isTrue(true as Equal<null, typeof x>)
113
- })
114
- })
115
-
116
- describe('assertType.noNull()', () => {
117
- test('ensure the input type does not contain null', () => {
118
- assertType.noNull(undefined)
119
- assertType.noNull(1)
120
- assertType.noNull(true)
121
- assertType.noNull('a')
122
- assertType.noNull([])
123
- assertType.noNull({})
124
-
125
- // These fails
126
- // assertType.noNull(null)
127
- // assertType.noNull(undefined as undefined | null)
128
- })
129
- test('null throws TypeError', () => {
130
- a.throws(() => assertType.noNull(null as any), TypeError)
131
- })
132
- })
133
-
134
- describe('assertType.isNumber()', () => {
135
- test('ensure the input type is number and nothing else', () => {
136
- assertType.isNumber(0)
137
-
138
- // These fails
139
- // assertType.isNumber(undefined)
140
- // assertType.isNumber(null)
141
- // assertType.isNumber(true)
142
- // assertType.isNumber('a')
143
- // assertType.isNumber([])
144
- // assertType.isNumber({})
145
- // assertType.isNumber(1 as number | undefined)
146
- // assertType.isNumber(1 as unknown)
147
- })
148
- test('not number throws TypeError', () => {
149
- a.throws(() => assertType.isNumber(undefined as any), TypeError)
150
- })
151
- test('narrow any to number', () => {
152
- const x: any = 1
153
- assertType.isNumber(x)
154
- assertType.isTrue(true as Equal<number, typeof x>)
155
- })
156
- })
157
-
158
- describe('assertType.noNumber()', () => {
159
- test('ensure the input type does not contain number', () => {
160
- assertType.noNumber(undefined)
161
- assertType.noNumber(null)
162
- assertType.noNumber(true)
163
- assertType.noNumber('a')
164
- assertType.noNumber([])
165
- assertType.noNumber({})
166
-
167
- // These fails
168
- // assertType.noNumber(1)
169
- // assertType.noNumber(1 as number | undefined)
170
- })
171
- test('number throws TypeError', () => {
172
- a.throws(() => assertType.noNumber(1 as any), TypeError)
173
- })
174
- })
175
-
176
- describe('assertType.isBoolean()', () => {
177
- test('ensure the input type is boolean and nothing else', () => {
178
- assertType.isBoolean(true)
179
- assertType.isBoolean(false)
180
-
181
- // These fails
182
- // assertType.isBoolean(undefined)
183
- // assertType.isBoolean(null)
184
- // assertType.isBoolean(1)
185
- // assertType.isBoolean('a')
186
- // assertType.isBoolean([])
187
- // assertType.isBoolean({})
188
- // assertType.isBoolean(true as boolean | undefined)
189
- })
190
- test('not boolean throws TypeError', () => {
191
- a.throws(() => assertType.isBoolean(undefined as any), TypeError)
192
- })
193
- test('narrow any to boolean', () => {
194
- const x: any = true
195
- assertType.isBoolean(x)
196
- assertType.isTrue(true as Equal<boolean, typeof x>)
197
- })
198
- })
199
-
200
- describe('assertType.noBoolean()', () => {
201
- test('ensure the input type does not contain boolean', () => {
202
- assertType.noBoolean(undefined)
203
- assertType.noBoolean(null)
204
- assertType.noBoolean(1)
205
- assertType.noBoolean('a')
206
- assertType.noBoolean([])
207
- assertType.noBoolean({})
208
-
209
- // These fails
210
- // assertType.noBoolean(true)
211
- // assertType.noBoolean(true as boolean | undefined)
212
- })
213
- test('boolean throws TypeError', () => {
214
- a.throws(() => assertType.noBoolean(true as any), TypeError)
215
- })
216
- })
217
-
218
- describe('assertType.isTrue()', () => {
219
- test('ensure the input type is true and nothing else', () => {
220
- assertType.isTrue(true)
221
-
222
- // These fails
223
- // assertType.isTrue(undefined)
224
- // assertType.isTrue(null)
225
- // assertType.isTrue(1)
226
- // assertType.isTrue('a')
227
- // assertType.isTrue(false)
228
- // assertType.isTrue([])
229
- // assertType.isTrue({})
230
- // assertType.isTrue(true as true | undefined)
231
- // assertType.isTrue(true as unknown)
232
- })
233
- test('not true throws TypeError', () => {
234
- a.throws(() => assertType.isTrue(undefined as any), TypeError)
235
- })
236
- test('narrow any to true', () => {
237
- const x: any = true
238
- assertType.isTrue(x)
239
- assertType.isTrue(true as Equal<true, typeof x>)
240
- })
241
- })
242
-
243
- describe('assertType.noTrue()', () => {
244
- test('ensure the input type does not contain boolean', () => {
245
- assertType.noTrue(false)
246
- assertType.noTrue(undefined)
247
- assertType.noTrue(null)
248
- assertType.noTrue(1)
249
- assertType.noTrue('a')
250
- assertType.noTrue([])
251
- assertType.noTrue({})
252
-
253
- // These fails
254
- // assertType.noTrue(true)
255
- // assertType.noTrue(true as true | undefined)
256
- // assertType.noTrue(true as boolean | undefined)
257
- })
258
- test('true throws TypeError', () => {
259
- a.throws(() => assertType.noTrue(true as any), TypeError)
260
- })
261
- })
262
-
263
- describe('assertType.isFalse()', () => {
264
- test('ensure the input type is false and nothing else', () => {
265
- assertType.isFalse(false)
266
-
267
- a.throws(() => assertType.isFalse(true as any), TypeError)
268
- const x: any = false
269
- assertType.isFalse(x)
270
- // `x` is narrowed to `true` here
271
- assertType.isFalse(x)
272
-
273
- // These fails
274
- // assertType.isFalse(undefined)
275
- // assertType.isFalse(null)
276
- // assertType.isFalse(1)
277
- // assertType.isFalse('a')
278
- // assertType.isFalse(false)
279
- // assertType.isFalse([])
280
- // assertType.isFalse({})
281
- // assertType.isFalse(false as false | undefined)
282
- // assertType.isFalse(false as unknown)
283
- })
284
- test('boolean throws TypeError', () => {
285
- a.throws(() => assertType.noBoolean(true as any), TypeError)
286
- })
287
- })
288
-
289
- describe('assertType.noFalse()', () => {
290
- test('ensure the input type does not contain boolean', () => {
291
- assertType.noFalse(true)
292
- assertType.noFalse(undefined)
293
- assertType.noFalse(null)
294
- assertType.noFalse(1)
295
- assertType.noFalse('a')
296
- assertType.noFalse([])
297
- assertType.noFalse({})
298
-
299
- // These fails
300
- // assertType.noFalse(false)
301
- // assertType.noFalse(false as false | undefined)
302
- // assertType.noFalse(false as boolean | undefined)
303
- })
304
- test('false throws TypeError', () => {
305
- a.throws(() => assertType.noFalse(false as any), TypeError)
306
- })
307
- })
308
-
309
- describe('assertType.isString()', () => {
310
- test('ensure the input type is string and nothing else', () => {
311
- assertType.isString('a')
312
-
313
- // These fails
314
- // assertType.isString(undefined)
315
- // assertType.isString(null)
316
- // assertType.isString(1)
317
- // assertType.isString(true)
318
- // assertType.isString([])
319
- // assertType.isString({})
320
- // assertType.isString('a' as string | undefined)
321
- // assertType.isString('a' as unknown)
322
- })
323
- test('not string throws TypeError', () => {
324
- a.throws(() => assertType.isString(undefined as any), TypeError)
325
- })
326
- test('narrow any to string', () => {
327
- const x: any = ''
328
- assertType.isString(x)
329
- assertType.isTrue(true as Equal<string, typeof x>)
330
- })
331
- })
332
-
333
- describe('assertType.noString()', () => {
334
- test('ensure the input type does not contain boolean', () => {
335
- assertType.noString(undefined)
336
- assertType.noString(null)
337
- assertType.noString(1)
338
- assertType.noString(true)
339
- assertType.noString([])
340
- assertType.noString({})
341
-
342
- // These fails
343
- // assertType.noString('a')
344
- // assertType.noString('a' as string | undefined)
345
- })
346
- test('string throws TypeError', () => {
347
- a.throws(() => assertType.noString('' as any), TypeError)
348
- })
349
- })
350
-
351
- describe('assertType.isFunction()', () => {
352
- test('ensure the input type is function and nothing else', () => {
353
- assertType.isFunction(() => { })
354
- assertType.isFunction(function () { })
355
-
356
- // These fails
357
- // assertType.isFunction(undefined)
358
- // assertType.isFunction(null)
359
- // assertType.isFunction(1)
360
- // assertType.isFunction('a')
361
- // assertType.isFunction([])
362
- // assertType.isFunction({})
363
- // assertType.isFunction((() => { }) as AnyFunction | undefined)
364
- })
365
- test('not function throws TypeError', () => {
366
- a.throws(() => assertType.isFunction(undefined as any), TypeError)
367
- })
368
- test('narrow any to function', () => {
369
- const x: any = () => { }
370
- assertType.isFunction(x)
371
- assertType.isTrue(true as Equal<AnyFunction, typeof x>)
372
- })
373
- })
374
-
375
- describe('assertType.noFunction()', () => {
376
- test('ensure the input type does not contain function', () => {
377
- assertType.noFunction(undefined)
378
- assertType.noFunction(null)
379
- assertType.noFunction(1)
380
- assertType.noFunction('a')
381
- assertType.noFunction([])
382
- assertType.noFunction({})
383
-
384
- // These fails
385
- // assertType.noFunction(() => {})
386
- // assertType.noFunction((() => {}) as AnyFunction | undefined)
387
- })
388
- test('function throws TypeError', () => {
389
- a.throws(() => assertType.noFunction((() => { }) as any), TypeError)
390
- })
391
- })
392
-
393
- describe('assertType.isConstructor()', () => {
394
- test('ensure the input type is constructor and nothing else', () => {
395
- class Foo { }
396
- assertType.isConstructor(Foo)
397
-
398
- // These fails
399
- // assertType.isConstructor(function () { })
400
- // assertType.isConstructor(undefined)
401
- // assertType.isConstructor(null)
402
- // assertType.isConstructor(1)
403
- // assertType.isConstructor('a')
404
- // assertType.isConstructor([])
405
- // assertType.isConstructor({})
406
- // assertType.isConstructor((() => { }) as AnyFunction | undefined)
407
- })
408
- test('not constructor throws TypeError', () => {
409
- a.throws(() => assertType.isConstructor(undefined as any), TypeError)
410
- })
411
- test('narrow any to constructor', () => {
412
- class Foo { }
413
- const x: any = Foo
414
- assertType.isConstructor(x)
415
- assertType.isTrue(true as Equal<AnyConstructor, typeof x>)
416
- })
417
- })
418
-
419
- describe('assertType.isError()', () => {
420
- test('ensure the input type is instance of Error and nothing else', () => {
421
- assertType.isError(new Error('x'))
422
-
423
- a.throws(() => assertType.isError(false as any), TypeError)
424
- const x: any = new Error()
425
- assertType.isError(x)
426
- // `x` is narrowed to `true` here
427
- assertType.isError(x)
428
-
429
- // These fails
430
- // assertType.isError(undefined)
431
- // assertType.isError(null)
432
- // assertType.isError(1)
433
- // assertType.isError(true)
434
- // assertType.isError([])
435
- // assertType.isError({})
436
- // assertType.isError('a')
437
- // assertType.isError(new Error() as Error | undefined)
438
- // assertType.isError(new Error() as unknown)
439
- })
440
-
441
- test('not error throws TypeError', () => {
442
- a.throws(() => assertType.isError(undefined as any), TypeError)
443
- })
444
- test('narrow any to Error', () => {
445
- const x: any = new Error('hello')
446
- assertType.isError(x)
447
- assertType.isTrue(true as Equal<Error, typeof x>)
448
- })
449
- })
450
-
451
- describe('assertType.noError()', () => {
452
- test('ensure the input type does not contain Error', () => {
453
- assertType.noError(undefined)
454
- assertType.noError(null)
455
- assertType.noError(1)
456
- assertType.noError('a')
457
- assertType.noError([])
458
- assertType.noError({})
459
-
460
- // These fails
461
- // assertType.noError(new Error('a'))
462
- // assertType.noError(new Error('a') as Error | undefined)
463
- })
464
- test('error instance throws TypeError', () => {
465
- a.throws(() => assertType.noError(new Error('a') as any), TypeError)
466
- })
467
- })
468
-
469
- describe('assertType.isNever()', () => {
470
- test('ensure the input type is never and nothing else', () => {
471
- const s: never = 0 as never
472
- assertType.isNever(s)
473
-
474
- // these fails
475
- // assertType.isNever(undefined)
476
- // assertType.isNever(null)
477
- // assertType.isNever(1)
478
- // assertType.isNever('a')
479
- // assertType.isNever(false)
480
- // assertType.isNever([])
481
- // assertType.isNever({})
482
- // assertType.isNever(x as any)
483
- // assertType.isNever(false as never | undefined)
484
- // assertType.isNever(false as unknown)
485
- })
486
- test('boolean throws TypeError', () => {
487
- a.throws(() => assertType.noBoolean(true as any), TypeError)
488
- })
489
- })
490
-
491
- describe('assertType.custom', () => {
492
- test('specify T in the validator', () => {
493
- const isBool = assertType.custom((s: boolean) => typeof s === 'boolean')
494
- const s: unknown = false
495
- expect(isBool(s)).toBe(undefined)
496
- })
497
- test('specify T at type declaration', () => {
498
- const isBool = assertType.custom<boolean>(s => typeof s === 'boolean')
499
- const s: unknown = false
500
- expect(isBool(s)).toBe(undefined)
501
- })
502
- test('error message contains info from validator', () => {
503
- const isBool = assertType.custom<boolean>(s => typeof s === 'boolean')
504
- const s: unknown = 1
505
- a.throws(() => isBool(s), e => /subject fails to satisfy s => typeof s === 'boolean'/.test(e))
506
- })
507
- })
@@ -1,28 +0,0 @@
1
- import { assertType, Equal } from '..'
2
- import { B } from '.'
3
-
4
- test('B.BitNot<T>', () => {
5
- assertType.isTrue(true as Equal<B.BitNot<1>, 0>)
6
- assertType.isTrue(true as Equal<B.BitNot<0>, 1>)
7
- })
8
-
9
- test('B.BitAnd<A, B>', () => {
10
- assertType.isTrue(true as Equal<B.BitAnd<1, 1>, 1>)
11
- assertType.isTrue(true as Equal<B.BitAnd<1, 0>, 0>)
12
- assertType.isTrue(true as Equal<B.BitAnd<0, 1>, 0>)
13
- assertType.isTrue(true as Equal<B.BitAnd<0, 0>, 0>)
14
- })
15
-
16
- test('B.BitOr<A, B>', () => {
17
- assertType.isTrue(true as Equal<B.BitOr<1, 1>, 1>)
18
- assertType.isTrue(true as Equal<B.BitOr<1, 0>, 1>)
19
- assertType.isTrue(true as Equal<B.BitOr<0, 1>, 1>)
20
- assertType.isTrue(true as Equal<B.BitOr<0, 0>, 0>)
21
- })
22
-
23
- test('B.BitXor<A, B>', () => {
24
- assertType.isTrue(true as Equal<B.BitXor<1, 1>, 0>)
25
- assertType.isTrue(true as Equal<B.BitXor<1, 0>, 1>)
26
- assertType.isTrue(true as Equal<B.BitXor<0, 1>, 1>)
27
- assertType.isTrue(true as Equal<B.BitXor<0, 0>, 0>)
28
- })
@@ -1,13 +0,0 @@
1
- import { AnyConstructor } from '..'
2
-
3
- test('basic', () => {
4
- const a = function () { } as any as AnyConstructor
5
-
6
- new a()
7
- })
8
-
9
- test('specify params with tuple', () => {
10
- const a = function () { } as any as AnyConstructor<[count: number, value: string]>
11
-
12
- new a(1, 'a')
13
- })
@@ -1,35 +0,0 @@
1
- import { AnyConstructor, assertType, isConstructor } from '..'
2
-
3
- test('check constructor', () => {
4
- const x: unknown = Error
5
- if (isConstructor(x))
6
- assertType<AnyConstructor>(x)
7
- })
8
-
9
- test('check not constructor', () => {
10
- expect(isConstructor(() => { })).toBe(false)
11
- })
12
-
13
- test('check throw function', () => {
14
- expect(isConstructor(() => { throw new Error() })).toBe(false)
15
- })
16
-
17
- test('check throwing constructor is still true', () => {
18
- class Foo { constructor() { throw new Error() } }
19
- expect(isConstructor(Foo)).toBe(true)
20
- })
21
-
22
- test('constructor throwing non-error', () => {
23
- class Foo { constructor() { throw 'abc' } }
24
- expect(isConstructor(Foo)).toBe(true)
25
- })
26
-
27
- test('constructor throwing undefined', () => {
28
- class Foo { constructor() { throw undefined } }
29
- expect(isConstructor(Foo)).toBe(true)
30
- })
31
-
32
- test('class with params returns true', () => {
33
- class Boo { constructor(public a: number) { } }
34
- expect(isConstructor(Boo)).toBe(true)
35
- })
@@ -1,21 +0,0 @@
1
- import { AnyFunction, assertType } from '..'
2
-
3
- test('basic', () => {
4
- function doCallback(cb: AnyFunction) {
5
- cb()
6
- }
7
-
8
- doCallback(() => { })
9
- doCallback(_ => { })
10
- doCallback((a: number, b: number) => a + b)
11
- })
12
-
13
- test('define param as tuple', () => {
14
- const foo: AnyFunction<[number, string]> = x => x
15
- foo(1, 'a')
16
- })
17
-
18
- test('define result type', () => {
19
- const foo: AnyFunction<string[], string> = x => x
20
- assertType.isString(foo('a'))
21
- })
@@ -1,7 +0,0 @@
1
- import { assertType, ChainFn, Equal } from '..'
2
-
3
- test('return type is the same as input type', () => {
4
- type A = ChainFn<number>
5
-
6
- assertType.isTrue(true as Equal<Parameters<A>[0], ReturnType<A>>)
7
- })
@@ -1,42 +0,0 @@
1
- import { assertType, CanAssign, canAssign } from '..'
2
- import { Just, just, Maybe, none, None } from './Maybe'
3
-
4
- test('just(value) returns Maybe<T>', () => {
5
- assertType<Maybe<number>>(just(1))
6
- })
7
-
8
- test('just(undefined) returns Maybe<T>', () => {
9
- const b: boolean | undefined = undefined
10
- assertType<Maybe<boolean>>(just(b))
11
- })
12
-
13
- test('none<T>() returns Maybe<T>', () => {
14
- assertType<Maybe<boolean>>(none<boolean>())
15
- })
16
-
17
- test('unwrap Maybe<T> returns value', () => {
18
- const maybe = just('abc')
19
- const actual = maybe.unwrap()
20
-
21
- assertType<string>(actual)
22
- expect(actual).toBe('abc')
23
- })
24
-
25
- test('None can assign to Maybe<T>', () => {
26
- const actual = none<number>()
27
-
28
- assertType.isTrue(true as CanAssign<typeof actual, Maybe<number>>)
29
- assertType.isTrue(true as CanAssign<None<number>, Maybe<number>>)
30
- assertType.isTrue(canAssign<Maybe<number>>()(none<number>()))
31
- })
32
-
33
- test('Just<number can assign to Maybe<number>', () => {
34
- assertType.isTrue(true as CanAssign<Just<number>, Maybe<number>>)
35
- assertType.isTrue(canAssign<Maybe<number>>()(just(1)))
36
- })
37
-
38
- test('Just<string> is not assignable to Maybe<number>', () => {
39
- assertType.isFalse(false as CanAssign<Just<'abc'>, Maybe<number>>)
40
-
41
- assertType.isTrue(canAssign<Maybe<number>>(false)(just('abc')))
42
- })
@@ -1,32 +0,0 @@
1
- import { compose, isType } from '..'
2
-
3
- test('works with endofunctors: +2 *3', () => {
4
- const plus2 = (x: number) => x + 2
5
- const multiply3 = (x: number) => x * 3
6
-
7
- const a = compose(plus2, multiply3)
8
-
9
- isType.equal<true, (a: number) => number, typeof a>()
10
- expect(a(2)).toBe(12)
11
- })
12
-
13
- test('cross types', () => {
14
- const n2s = (n: number) => '' + n
15
- const len1 = (s: string) => s.length === 1
16
-
17
- const isSingleDigit = compose(n2s, len1)
18
-
19
- isType.equal<true, (n: number) => boolean, typeof isSingleDigit>()
20
- expect(isSingleDigit(1)).toBe(true)
21
- expect(isSingleDigit(10)).toBe(false)
22
- })
23
-
24
- test('multiple params first function', () => {
25
- const add = (a: number, b: number) => a + b
26
- const multiply3 = (x: number) => x * 3
27
-
28
- const a = compose(add, multiply3)
29
-
30
- isType.equal<true, (a: number, b: number) => number, typeof a>()
31
- expect(a(2, 2)).toBe(12)
32
- })
package/ts/index.spec.ts DELETED
@@ -1,7 +0,0 @@
1
- // import { T, types } from '.'
2
-
3
- // test('export types also as T', () => {
4
- // expect(T).toBe(types)
5
- // })
6
-
7
- test.todo('no test')