type-plus 4.9.1 → 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 (724) hide show
  1. package/cjs/ComposableTypes.d.ts +1 -0
  2. package/cjs/ComposableTypes.d.ts.map +1 -0
  3. package/cjs/JSONTypes.d.ts +1 -0
  4. package/cjs/JSONTypes.d.ts.map +1 -0
  5. package/cjs/JSONTypes.js.map +1 -1
  6. package/cjs/PrimitiveTypes.d.ts +1 -0
  7. package/cjs/PrimitiveTypes.d.ts.map +1 -0
  8. package/cjs/UnionKeys.d.ts +1 -0
  9. package/cjs/UnionKeys.d.ts.map +1 -0
  10. package/cjs/array/CommonPropKeys.d.ts +2 -1
  11. package/cjs/array/CommonPropKeys.d.ts.map +1 -0
  12. package/cjs/array/Concat.d.ts +1 -0
  13. package/cjs/array/Concat.d.ts.map +1 -0
  14. package/cjs/array/CreateTuple.d.ts +2 -1
  15. package/cjs/array/CreateTuple.d.ts.map +1 -0
  16. package/cjs/array/Filter.d.ts +1 -0
  17. package/cjs/array/Filter.d.ts.map +1 -0
  18. package/cjs/array/FindFirst.d.ts +1 -0
  19. package/cjs/array/FindFirst.d.ts.map +1 -0
  20. package/cjs/array/FindLast.d.ts +1 -0
  21. package/cjs/array/FindLast.d.ts.map +1 -0
  22. package/cjs/array/Head.d.ts +1 -0
  23. package/cjs/array/Head.d.ts.map +1 -0
  24. package/cjs/array/IntersectOfProps.d.ts +3 -2
  25. package/cjs/array/IntersectOfProps.d.ts.map +1 -0
  26. package/cjs/array/IsArray.d.ts +1 -0
  27. package/cjs/array/IsArray.d.ts.map +1 -0
  28. package/cjs/array/Last.d.ts +1 -0
  29. package/cjs/array/Last.d.ts.map +1 -0
  30. package/cjs/array/PadLeft.d.ts +4 -3
  31. package/cjs/array/PadLeft.d.ts.map +1 -0
  32. package/cjs/array/Reverse.d.ts +1 -0
  33. package/cjs/array/Reverse.d.ts.map +1 -0
  34. package/cjs/array/Some.d.ts +4 -3
  35. package/cjs/array/Some.d.ts.map +1 -0
  36. package/cjs/array/Tail.d.ts +2 -1
  37. package/cjs/array/Tail.d.ts.map +1 -0
  38. package/cjs/array/UnionOfProps.d.ts +3 -2
  39. package/cjs/array/UnionOfProps.d.ts.map +1 -0
  40. package/cjs/array/UnionOfValues.d.ts +1 -0
  41. package/cjs/array/UnionOfValues.d.ts.map +1 -0
  42. package/cjs/array/drop.d.ts +3 -2
  43. package/cjs/array/drop.d.ts.map +1 -0
  44. package/cjs/array/index.d.ts +20 -19
  45. package/cjs/array/index.d.ts.map +1 -0
  46. package/cjs/array/index.js +3 -3
  47. package/cjs/array/index.js.map +1 -1
  48. package/cjs/array/literalArray.d.ts +2 -1
  49. package/cjs/array/literalArray.d.ts.map +1 -0
  50. package/cjs/array/reduceWhile.d.ts +1 -0
  51. package/cjs/array/reduceWhile.d.ts.map +1 -0
  52. package/cjs/assertion/assertType.d.ts +3 -2
  53. package/cjs/assertion/assertType.d.ts.map +1 -0
  54. package/cjs/assertion/assertType.js +3 -3
  55. package/cjs/assertion/assertType.js.map +1 -1
  56. package/cjs/assertion/index.d.ts +2 -1
  57. package/cjs/assertion/index.d.ts.map +1 -0
  58. package/cjs/assertion/index.js +1 -1
  59. package/cjs/assertion/index.js.map +1 -1
  60. package/cjs/class/AnyConstructor.d.ts +1 -0
  61. package/cjs/class/AnyConstructor.d.ts.map +1 -0
  62. package/cjs/class/index.d.ts +3 -2
  63. package/cjs/class/index.d.ts.map +1 -0
  64. package/cjs/class/index.js +1 -1
  65. package/cjs/class/index.js.map +1 -1
  66. package/cjs/class/isConstructor.d.ts +2 -1
  67. package/cjs/class/isConstructor.d.ts.map +1 -0
  68. package/cjs/function/AnyFunction.d.ts +1 -0
  69. package/cjs/function/AnyFunction.d.ts.map +1 -0
  70. package/cjs/function/index.d.ts +2 -1
  71. package/cjs/function/index.d.ts.map +1 -0
  72. package/cjs/functional/ChainFn.d.ts +1 -0
  73. package/cjs/functional/ChainFn.d.ts.map +1 -0
  74. package/cjs/functional/compose.d.ts +3 -2
  75. package/cjs/functional/compose.d.ts.map +1 -0
  76. package/cjs/functional/index.d.ts +3 -2
  77. package/cjs/functional/index.d.ts.map +1 -0
  78. package/cjs/functional/index.js +1 -1
  79. package/cjs/functional/index.js.map +1 -1
  80. package/cjs/index.d.ts +18 -17
  81. package/cjs/index.d.ts.map +1 -0
  82. package/cjs/index.js +14 -14
  83. package/cjs/index.js.map +1 -1
  84. package/cjs/math/Abs.d.ts +2 -1
  85. package/cjs/math/Abs.d.ts.map +1 -0
  86. package/cjs/math/Add.d.ts +7 -6
  87. package/cjs/math/Add.d.ts.map +1 -0
  88. package/cjs/math/Digit.d.ts +5 -4
  89. package/cjs/math/Digit.d.ts.map +1 -0
  90. package/cjs/math/GreaterThan.d.ts +7 -6
  91. package/cjs/math/GreaterThan.d.ts.map +1 -0
  92. package/cjs/math/IsPositive.d.ts +1 -0
  93. package/cjs/math/IsPositive.d.ts.map +1 -0
  94. package/cjs/math/IsWhole.d.ts +1 -0
  95. package/cjs/math/IsWhole.d.ts.map +1 -0
  96. package/cjs/math/Max.d.ts +3 -2
  97. package/cjs/math/Max.d.ts.map +1 -0
  98. package/cjs/math/Subtract.d.ts +7 -6
  99. package/cjs/math/Subtract.d.ts.map +1 -0
  100. package/cjs/math/index.d.ts +9 -8
  101. package/cjs/math/index.d.ts.map +1 -0
  102. package/cjs/nodejs/index.d.ts +2 -1
  103. package/cjs/nodejs/index.d.ts.map +1 -0
  104. package/cjs/nodejs/index.js +1 -1
  105. package/cjs/nodejs/index.js.map +1 -1
  106. package/cjs/nodejs/isNodeError.d.ts +1 -0
  107. package/cjs/nodejs/isNodeError.d.ts.map +1 -0
  108. package/cjs/nominal-types/Brand.d.ts +3 -2
  109. package/cjs/nominal-types/Brand.d.ts.map +1 -0
  110. package/cjs/nominal-types/Brand.js +2 -2
  111. package/cjs/nominal-types/Brand.js.map +1 -1
  112. package/cjs/nominal-types/Flavor.d.ts +3 -2
  113. package/cjs/nominal-types/Flavor.d.ts.map +1 -0
  114. package/cjs/nominal-types/Flavor.js +2 -2
  115. package/cjs/nominal-types/Flavor.js.map +1 -1
  116. package/cjs/nominal-types/index.d.ts +4 -3
  117. package/cjs/nominal-types/index.d.ts.map +1 -0
  118. package/cjs/nominal-types/index.js +3 -3
  119. package/cjs/nominal-types/index.js.map +1 -1
  120. package/cjs/nominal-types/nominalMatch.d.ts +3 -2
  121. package/cjs/nominal-types/nominalMatch.d.ts.map +1 -0
  122. package/cjs/nominal-types/nominalMatch.js +2 -2
  123. package/cjs/nominal-types/nominalMatch.js.map +1 -1
  124. package/cjs/nominal-types/types.d.ts +1 -0
  125. package/cjs/nominal-types/types.d.ts.map +1 -0
  126. package/cjs/object/ANotB.d.ts +5 -4
  127. package/cjs/object/ANotB.d.ts.map +1 -0
  128. package/cjs/object/AnyRecord.d.ts +1 -0
  129. package/cjs/object/AnyRecord.d.ts.map +1 -0
  130. package/cjs/object/ExcludePropType.d.ts +1 -0
  131. package/cjs/object/ExcludePropType.d.ts.map +1 -0
  132. package/cjs/object/IsDisjoint.d.ts +4 -3
  133. package/cjs/object/IsDisjoint.d.ts.map +1 -0
  134. package/cjs/object/IsRecord.d.ts +1 -0
  135. package/cjs/object/IsRecord.d.ts.map +1 -0
  136. package/cjs/object/KeyTypes.d.ts +1 -0
  137. package/cjs/object/KeyTypes.d.ts.map +1 -0
  138. package/cjs/object/KeyofOptional.d.ts +1 -0
  139. package/cjs/object/KeyofOptional.d.ts.map +1 -0
  140. package/cjs/object/KeysWithDiffType.d.ts +4 -3
  141. package/cjs/object/KeysWithDiffType.d.ts.map +1 -0
  142. package/cjs/object/KnownKeys.d.ts +2 -1
  143. package/cjs/object/KnownKeys.d.ts.map +1 -0
  144. package/cjs/object/OptionalKeys.d.ts +2 -1
  145. package/cjs/object/OptionalKeys.d.ts.map +1 -0
  146. package/cjs/object/Partial.d.ts +4 -3
  147. package/cjs/object/Partial.d.ts.map +1 -0
  148. package/cjs/object/RecursiveIntersect.d.ts +2 -1
  149. package/cjs/object/RecursiveIntersect.d.ts.map +1 -0
  150. package/cjs/object/RecursivePartial.d.ts +2 -1
  151. package/cjs/object/RecursivePartial.d.ts.map +1 -0
  152. package/cjs/object/RecursiveRequired.d.ts +2 -1
  153. package/cjs/object/RecursiveRequired.d.ts.map +1 -0
  154. package/cjs/object/Required.d.ts +1 -0
  155. package/cjs/object/Required.d.ts.map +1 -0
  156. package/cjs/object/RequiredKeys.d.ts +3 -2
  157. package/cjs/object/RequiredKeys.d.ts.map +1 -0
  158. package/cjs/object/SpreadRecord.d.ts +2 -1
  159. package/cjs/object/SpreadRecord.d.ts.map +1 -0
  160. package/cjs/object/ValueOf.d.ts +1 -0
  161. package/cjs/object/ValueOf.d.ts.map +1 -0
  162. package/cjs/object/everyKey.d.ts +2 -1
  163. package/cjs/object/everyKey.d.ts.map +1 -0
  164. package/cjs/object/facade.d.ts +2 -1
  165. package/cjs/object/facade.d.ts.map +1 -0
  166. package/cjs/object/filterKey.d.ts +2 -1
  167. package/cjs/object/filterKey.d.ts.map +1 -0
  168. package/cjs/object/findKey.d.ts +2 -1
  169. package/cjs/object/findKey.d.ts.map +1 -0
  170. package/cjs/object/forEachKey.d.ts +2 -1
  171. package/cjs/object/forEachKey.d.ts.map +1 -0
  172. package/cjs/object/getField.d.ts +2 -1
  173. package/cjs/object/getField.d.ts.map +1 -0
  174. package/cjs/object/hasKey.d.ts +2 -1
  175. package/cjs/object/hasKey.d.ts.map +1 -0
  176. package/cjs/object/hasProperty.d.ts +2 -1
  177. package/cjs/object/hasProperty.d.ts.map +1 -0
  178. package/cjs/object/index.d.ts +37 -36
  179. package/cjs/object/index.d.ts.map +1 -0
  180. package/cjs/object/index.js +18 -18
  181. package/cjs/object/index.js.map +1 -1
  182. package/cjs/object/mapKey.d.ts +2 -1
  183. package/cjs/object/mapKey.d.ts.map +1 -0
  184. package/cjs/object/mapProperties.d.ts +3 -2
  185. package/cjs/object/mapProperties.d.ts.map +1 -0
  186. package/cjs/object/mapProperties.js +2 -2
  187. package/cjs/object/mapProperties.js.map +1 -1
  188. package/cjs/object/omit.d.ts +4 -3
  189. package/cjs/object/omit.d.ts.map +1 -0
  190. package/cjs/object/omit.js +2 -2
  191. package/cjs/object/omit.js.map +1 -1
  192. package/cjs/object/pick.d.ts +3 -2
  193. package/cjs/object/pick.d.ts.map +1 -0
  194. package/cjs/object/pick.js +2 -2
  195. package/cjs/object/pick.js.map +1 -1
  196. package/cjs/object/record.d.ts +3 -2
  197. package/cjs/object/record.d.ts.map +1 -0
  198. package/cjs/object/reduceKey.d.ts +2 -1
  199. package/cjs/object/reduceKey.d.ts.map +1 -0
  200. package/cjs/object/replaceProperty.d.ts +2 -1
  201. package/cjs/object/replaceProperty.d.ts.map +1 -0
  202. package/cjs/object/someKey.d.ts +2 -1
  203. package/cjs/object/someKey.d.ts.map +1 -0
  204. package/cjs/object/split.d.ts +3 -2
  205. package/cjs/object/split.d.ts.map +1 -0
  206. package/cjs/object/split.js +3 -3
  207. package/cjs/object/split.js.map +1 -1
  208. package/cjs/object/typeOverrideIncompatible.d.ts +2 -1
  209. package/cjs/object/typeOverrideIncompatible.d.ts.map +1 -0
  210. package/cjs/predicates/CanAssign.d.ts +3 -2
  211. package/cjs/predicates/CanAssign.d.ts.map +1 -0
  212. package/cjs/predicates/Equal.d.ts +1 -0
  213. package/cjs/predicates/Equal.d.ts.map +1 -0
  214. package/cjs/predicates/Extends.d.ts +1 -0
  215. package/cjs/predicates/Extends.d.ts.map +1 -0
  216. package/cjs/predicates/If.d.ts +1 -0
  217. package/cjs/predicates/If.d.ts.map +1 -0
  218. package/cjs/predicates/IsEmptyObject.d.ts +1 -0
  219. package/cjs/predicates/IsEmptyObject.d.ts.map +1 -0
  220. package/cjs/predicates/index.d.ts +9 -8
  221. package/cjs/predicates/index.d.ts.map +1 -0
  222. package/cjs/predicates/index.js +2 -2
  223. package/cjs/predicates/index.js.map +1 -1
  224. package/cjs/predicates/isType.d.ts +3 -2
  225. package/cjs/predicates/isType.d.ts.map +1 -0
  226. package/cjs/predicates/isType.js +2 -2
  227. package/cjs/predicates/isType.js.map +1 -1
  228. package/cjs/predicates/logical.d.ts +1 -0
  229. package/cjs/predicates/logical.d.ts.map +1 -0
  230. package/cjs/promise/PromiseValue.d.ts +1 -0
  231. package/cjs/promise/PromiseValue.d.ts.map +1 -0
  232. package/cjs/promise/PromiseValueMerge.d.ts +2 -1
  233. package/cjs/promise/PromiseValueMerge.d.ts.map +1 -0
  234. package/cjs/promise/index.d.ts +5 -4
  235. package/cjs/promise/index.d.ts.map +1 -0
  236. package/cjs/promise/index.js +2 -2
  237. package/cjs/promise/index.js.map +1 -1
  238. package/cjs/promise/isPromise.d.ts +1 -0
  239. package/cjs/promise/isPromise.d.ts.map +1 -0
  240. package/cjs/promise/mapSeries.d.ts +1 -0
  241. package/cjs/promise/mapSeries.d.ts.map +1 -0
  242. package/cjs/testing/index.d.ts +2 -1
  243. package/cjs/testing/index.d.ts.map +1 -0
  244. package/cjs/testing/index.js +1 -1
  245. package/cjs/testing/index.js.map +1 -1
  246. package/cjs/testing/stub.d.ts +3 -2
  247. package/cjs/testing/stub.d.ts.map +1 -0
  248. package/cjs/utils/NonNull.d.ts +1 -0
  249. package/cjs/utils/NonNull.d.ts.map +1 -0
  250. package/cjs/utils/NonUndefined.d.ts +1 -0
  251. package/cjs/utils/NonUndefined.d.ts.map +1 -0
  252. package/cjs/utils/Widen.d.ts +1 -0
  253. package/cjs/utils/Widen.d.ts.map +1 -0
  254. package/cjs/utils/as.d.ts +1 -0
  255. package/cjs/utils/as.d.ts.map +1 -0
  256. package/cjs/utils/index.d.ts +5 -4
  257. package/cjs/utils/index.d.ts.map +1 -0
  258. package/cjs/utils/index.js +1 -1
  259. package/cjs/utils/index.js.map +1 -1
  260. package/esm/ComposableTypes.d.ts +3 -0
  261. package/esm/ComposableTypes.d.ts.map +1 -0
  262. package/esm/JSONTypes.d.ts +12 -0
  263. package/esm/JSONTypes.d.ts.map +1 -0
  264. package/esm/JSONTypes.js.map +1 -1
  265. package/esm/PrimitiveTypes.d.ts +2 -0
  266. package/esm/PrimitiveTypes.d.ts.map +1 -0
  267. package/esm/UnionKeys.d.ts +2 -0
  268. package/esm/UnionKeys.d.ts.map +1 -0
  269. package/esm/array/CommonPropKeys.d.ts +4 -0
  270. package/esm/array/CommonPropKeys.d.ts.map +1 -0
  271. package/esm/array/Concat.d.ts +2 -0
  272. package/esm/array/Concat.d.ts.map +1 -0
  273. package/esm/array/CreateTuple.d.ts +3 -0
  274. package/esm/array/CreateTuple.d.ts.map +1 -0
  275. package/esm/array/Filter.d.ts +3 -0
  276. package/esm/array/Filter.d.ts.map +1 -0
  277. package/esm/array/FindFirst.d.ts +3 -0
  278. package/esm/array/FindFirst.d.ts.map +1 -0
  279. package/esm/array/FindLast.d.ts +2 -0
  280. package/esm/array/FindLast.d.ts.map +1 -0
  281. package/esm/array/Head.d.ts +2 -0
  282. package/esm/array/Head.d.ts.map +1 -0
  283. package/esm/array/IntersectOfProps.d.ts +5 -0
  284. package/esm/array/IntersectOfProps.d.ts.map +1 -0
  285. package/esm/array/IsArray.d.ts +2 -0
  286. package/esm/array/IsArray.d.ts.map +1 -0
  287. package/esm/array/Last.d.ts +2 -0
  288. package/esm/array/Last.d.ts.map +1 -0
  289. package/esm/array/PadLeft.d.ts +5 -0
  290. package/esm/array/PadLeft.d.ts.map +1 -0
  291. package/esm/array/Reverse.d.ts +2 -0
  292. package/esm/array/Reverse.d.ts.map +1 -0
  293. package/esm/array/Some.d.ts +8 -0
  294. package/esm/array/Some.d.ts.map +1 -0
  295. package/esm/array/Tail.d.ts +3 -0
  296. package/esm/array/Tail.d.ts.map +1 -0
  297. package/esm/array/UnionOfProps.d.ts +5 -0
  298. package/esm/array/UnionOfProps.d.ts.map +1 -0
  299. package/esm/array/UnionOfValues.d.ts +3 -0
  300. package/esm/array/UnionOfValues.d.ts.map +1 -0
  301. package/esm/array/drop.d.ts +13 -0
  302. package/esm/array/drop.d.ts.map +1 -0
  303. package/esm/array/index.d.ts +20 -0
  304. package/esm/array/index.d.ts.map +1 -0
  305. package/esm/array/index.js +3 -3
  306. package/esm/array/index.js.map +1 -1
  307. package/esm/array/literalArray.d.ts +3 -0
  308. package/esm/array/literalArray.d.ts.map +1 -0
  309. package/esm/array/reduceWhile.d.ts +2 -0
  310. package/esm/array/reduceWhile.d.ts.map +1 -0
  311. package/esm/assertion/assertType.d.ts +29 -0
  312. package/esm/assertion/assertType.d.ts.map +1 -0
  313. package/esm/assertion/assertType.js +1 -1
  314. package/esm/assertion/assertType.js.map +1 -1
  315. package/esm/assertion/index.d.ts +2 -0
  316. package/esm/assertion/index.d.ts.map +1 -0
  317. package/esm/assertion/index.js +1 -1
  318. package/esm/assertion/index.js.map +1 -1
  319. package/esm/class/AnyConstructor.d.ts +2 -0
  320. package/esm/class/AnyConstructor.d.ts.map +1 -0
  321. package/esm/class/index.d.ts +3 -0
  322. package/esm/class/index.d.ts.map +1 -0
  323. package/esm/class/index.js +1 -1
  324. package/esm/class/index.js.map +1 -1
  325. package/esm/class/isConstructor.d.ts +3 -0
  326. package/esm/class/isConstructor.d.ts.map +1 -0
  327. package/esm/function/AnyFunction.d.ts +2 -0
  328. package/esm/function/AnyFunction.d.ts.map +1 -0
  329. package/esm/function/index.d.ts +2 -0
  330. package/esm/function/index.d.ts.map +1 -0
  331. package/esm/functional/ChainFn.d.ts +3 -0
  332. package/esm/functional/ChainFn.d.ts.map +1 -0
  333. package/esm/functional/compose.d.ts +4 -0
  334. package/esm/functional/compose.d.ts.map +1 -0
  335. package/esm/functional/index.d.ts +3 -0
  336. package/esm/functional/index.d.ts.map +1 -0
  337. package/esm/functional/index.js +1 -1
  338. package/esm/functional/index.js.map +1 -1
  339. package/esm/index.d.ts +19 -0
  340. package/esm/index.d.ts.map +1 -0
  341. package/esm/index.js +14 -14
  342. package/esm/index.js.map +1 -1
  343. package/esm/math/Abs.d.ts +3 -0
  344. package/esm/math/Abs.d.ts.map +1 -0
  345. package/esm/math/Add.d.ts +16 -0
  346. package/esm/math/Add.d.ts.map +1 -0
  347. package/esm/math/Digit.d.ts +97 -0
  348. package/esm/math/Digit.d.ts.map +1 -0
  349. package/esm/math/GreaterThan.d.ts +12 -0
  350. package/esm/math/GreaterThan.d.ts.map +1 -0
  351. package/esm/math/IsPositive.d.ts +2 -0
  352. package/esm/math/IsPositive.d.ts.map +1 -0
  353. package/esm/math/IsWhole.d.ts +2 -0
  354. package/esm/math/IsWhole.d.ts.map +1 -0
  355. package/esm/math/Max.d.ts +4 -0
  356. package/esm/math/Max.d.ts.map +1 -0
  357. package/esm/math/Subtract.d.ts +13 -0
  358. package/esm/math/Subtract.d.ts.map +1 -0
  359. package/esm/math/index.d.ts +9 -0
  360. package/esm/math/index.d.ts.map +1 -0
  361. package/esm/nodejs/index.d.ts +2 -0
  362. package/esm/nodejs/index.d.ts.map +1 -0
  363. package/esm/nodejs/index.js +1 -1
  364. package/esm/nodejs/index.js.map +1 -1
  365. package/esm/nodejs/isNodeError.d.ts +26 -0
  366. package/esm/nodejs/isNodeError.d.ts.map +1 -0
  367. package/esm/nominal-types/Brand.d.ts +11 -0
  368. package/esm/nominal-types/Brand.d.ts.map +1 -0
  369. package/esm/nominal-types/Brand.js +1 -1
  370. package/esm/nominal-types/Brand.js.map +1 -1
  371. package/esm/nominal-types/Flavor.d.ts +8 -0
  372. package/esm/nominal-types/Flavor.d.ts.map +1 -0
  373. package/esm/nominal-types/Flavor.js +1 -1
  374. package/esm/nominal-types/Flavor.js.map +1 -1
  375. package/esm/nominal-types/index.d.ts +4 -0
  376. package/esm/nominal-types/index.d.ts.map +1 -0
  377. package/esm/nominal-types/index.js +3 -3
  378. package/esm/nominal-types/index.js.map +1 -1
  379. package/esm/nominal-types/nominalMatch.d.ts +5 -0
  380. package/esm/nominal-types/nominalMatch.d.ts.map +1 -0
  381. package/esm/nominal-types/nominalMatch.js +1 -1
  382. package/esm/nominal-types/nominalMatch.js.map +1 -1
  383. package/esm/nominal-types/types.d.ts +3 -0
  384. package/esm/nominal-types/types.d.ts.map +1 -0
  385. package/esm/object/ANotB.d.ts +14 -0
  386. package/esm/object/ANotB.d.ts.map +1 -0
  387. package/esm/object/AnyRecord.d.ts +2 -0
  388. package/esm/object/AnyRecord.d.ts.map +1 -0
  389. package/esm/object/ExcludePropType.d.ts +4 -0
  390. package/esm/object/ExcludePropType.d.ts.map +1 -0
  391. package/esm/object/IsDisjoint.d.ts +5 -0
  392. package/esm/object/IsDisjoint.d.ts.map +1 -0
  393. package/esm/object/IsRecord.d.ts +2 -0
  394. package/esm/object/IsRecord.d.ts.map +1 -0
  395. package/esm/object/KeyTypes.d.ts +2 -0
  396. package/esm/object/KeyTypes.d.ts.map +1 -0
  397. package/esm/object/KeyofOptional.d.ts +3 -0
  398. package/esm/object/KeyofOptional.d.ts.map +1 -0
  399. package/esm/object/KeysWithDiffType.d.ts +7 -0
  400. package/esm/object/KeysWithDiffType.d.ts.map +1 -0
  401. package/esm/object/KnownKeys.d.ts +7 -0
  402. package/esm/object/KnownKeys.d.ts.map +1 -0
  403. package/esm/object/OptionalKeys.d.ts +8 -0
  404. package/esm/object/OptionalKeys.d.ts.map +1 -0
  405. package/esm/object/Partial.d.ts +7 -0
  406. package/esm/object/Partial.d.ts.map +1 -0
  407. package/esm/object/RecursiveIntersect.d.ts +5 -0
  408. package/esm/object/RecursiveIntersect.d.ts.map +1 -0
  409. package/esm/object/RecursivePartial.d.ts +5 -0
  410. package/esm/object/RecursivePartial.d.ts.map +1 -0
  411. package/esm/object/RecursiveRequired.d.ts +5 -0
  412. package/esm/object/RecursiveRequired.d.ts.map +1 -0
  413. package/esm/object/Required.d.ts +3 -0
  414. package/esm/object/Required.d.ts.map +1 -0
  415. package/esm/object/RequiredKeys.d.ts +7 -0
  416. package/esm/object/RequiredKeys.d.ts.map +1 -0
  417. package/esm/object/SpreadRecord.d.ts +3 -0
  418. package/esm/object/SpreadRecord.d.ts.map +1 -0
  419. package/esm/object/ValueOf.d.ts +2 -0
  420. package/esm/object/ValueOf.d.ts.map +1 -0
  421. package/esm/object/everyKey.d.ts +3 -0
  422. package/esm/object/everyKey.d.ts.map +1 -0
  423. package/esm/object/facade.d.ts +14 -0
  424. package/esm/object/facade.d.ts.map +1 -0
  425. package/esm/object/filterKey.d.ts +3 -0
  426. package/esm/object/filterKey.d.ts.map +1 -0
  427. package/esm/object/findKey.d.ts +3 -0
  428. package/esm/object/findKey.d.ts.map +1 -0
  429. package/esm/object/forEachKey.d.ts +3 -0
  430. package/esm/object/forEachKey.d.ts.map +1 -0
  431. package/esm/object/getField.d.ts +4 -0
  432. package/esm/object/getField.d.ts.map +1 -0
  433. package/esm/object/hasKey.d.ts +4 -0
  434. package/esm/object/hasKey.d.ts.map +1 -0
  435. package/esm/object/hasProperty.d.ts +3 -0
  436. package/esm/object/hasProperty.d.ts.map +1 -0
  437. package/esm/object/index.d.ts +37 -0
  438. package/esm/object/index.d.ts.map +1 -0
  439. package/esm/object/index.js +18 -18
  440. package/esm/object/index.js.map +1 -1
  441. package/esm/object/mapKey.d.ts +3 -0
  442. package/esm/object/mapKey.d.ts.map +1 -0
  443. package/esm/object/mapProperties.d.ts +6 -0
  444. package/esm/object/mapProperties.d.ts.map +1 -0
  445. package/esm/object/mapProperties.js +1 -1
  446. package/esm/object/mapProperties.js.map +1 -1
  447. package/esm/object/omit.d.ts +18 -0
  448. package/esm/object/omit.d.ts.map +1 -0
  449. package/esm/object/omit.js +1 -1
  450. package/esm/object/omit.js.map +1 -1
  451. package/esm/object/pick.d.ts +21 -0
  452. package/esm/object/pick.d.ts.map +1 -0
  453. package/esm/object/pick.js +1 -1
  454. package/esm/object/pick.js.map +1 -1
  455. package/esm/object/record.d.ts +4 -0
  456. package/esm/object/record.d.ts.map +1 -0
  457. package/esm/object/reduceKey.d.ts +4 -0
  458. package/esm/object/reduceKey.d.ts.map +1 -0
  459. package/esm/object/replaceProperty.d.ts +6 -0
  460. package/esm/object/replaceProperty.d.ts.map +1 -0
  461. package/esm/object/someKey.d.ts +3 -0
  462. package/esm/object/someKey.d.ts.map +1 -0
  463. package/esm/object/split.d.ts +82 -0
  464. package/esm/object/split.d.ts.map +1 -0
  465. package/esm/object/split.js +1 -1
  466. package/esm/object/split.js.map +1 -1
  467. package/esm/object/typeOverrideIncompatible.d.ts +3 -0
  468. package/esm/object/typeOverrideIncompatible.d.ts.map +1 -0
  469. package/esm/predicates/CanAssign.d.ts +7 -0
  470. package/esm/predicates/CanAssign.d.ts.map +1 -0
  471. package/esm/predicates/Equal.d.ts +5 -0
  472. package/esm/predicates/Equal.d.ts.map +1 -0
  473. package/esm/predicates/Extends.d.ts +5 -0
  474. package/esm/predicates/Extends.d.ts.map +1 -0
  475. package/esm/predicates/If.d.ts +2 -0
  476. package/esm/predicates/If.d.ts.map +1 -0
  477. package/esm/predicates/IsEmptyObject.d.ts +2 -0
  478. package/esm/predicates/IsEmptyObject.d.ts.map +1 -0
  479. package/esm/predicates/index.d.ts +12 -0
  480. package/esm/predicates/index.d.ts.map +1 -0
  481. package/esm/predicates/index.js +2 -2
  482. package/esm/predicates/index.js.map +1 -1
  483. package/esm/predicates/isType.d.ts +11 -0
  484. package/esm/predicates/isType.d.ts.map +1 -0
  485. package/esm/predicates/isType.js +1 -1
  486. package/esm/predicates/isType.js.map +1 -1
  487. package/esm/predicates/logical.d.ts +5 -0
  488. package/esm/predicates/logical.d.ts.map +1 -0
  489. package/esm/promise/PromiseValue.d.ts +2 -0
  490. package/esm/promise/PromiseValue.d.ts.map +1 -0
  491. package/esm/promise/PromiseValueMerge.d.ts +3 -0
  492. package/esm/promise/PromiseValueMerge.d.ts.map +1 -0
  493. package/esm/promise/index.d.ts +5 -0
  494. package/esm/promise/index.d.ts.map +1 -0
  495. package/esm/promise/index.js +2 -2
  496. package/esm/promise/index.js.map +1 -1
  497. package/esm/promise/isPromise.d.ts +2 -0
  498. package/esm/promise/isPromise.d.ts.map +1 -0
  499. package/esm/promise/mapSeries.d.ts +2 -0
  500. package/esm/promise/mapSeries.d.ts.map +1 -0
  501. package/esm/testing/index.d.ts +2 -0
  502. package/esm/testing/index.d.ts.map +1 -0
  503. package/esm/testing/index.js +1 -1
  504. package/esm/testing/index.js.map +1 -1
  505. package/esm/testing/stub.d.ts +10 -0
  506. package/esm/testing/stub.d.ts.map +1 -0
  507. package/esm/utils/NonNull.d.ts +2 -0
  508. package/esm/utils/NonNull.d.ts.map +1 -0
  509. package/esm/utils/NonUndefined.d.ts +2 -0
  510. package/esm/utils/NonUndefined.d.ts.map +1 -0
  511. package/esm/utils/Widen.d.ts +2 -0
  512. package/esm/utils/Widen.d.ts.map +1 -0
  513. package/esm/utils/as.d.ts +7 -0
  514. package/esm/utils/as.d.ts.map +1 -0
  515. package/esm/utils/index.d.ts +5 -0
  516. package/esm/utils/index.d.ts.map +1 -0
  517. package/esm/utils/index.js +1 -1
  518. package/esm/utils/index.js.map +1 -1
  519. package/package.json +47 -44
  520. package/ts/JSONTypes.ts +17 -18
  521. package/ts/array/CommonPropKeys.ts +18 -18
  522. package/ts/array/CreateTuple.ts +1 -1
  523. package/ts/array/IntersectOfProps.ts +20 -20
  524. package/ts/array/PadLeft.ts +3 -3
  525. package/ts/array/Some.ts +3 -3
  526. package/ts/array/Tail.ts +1 -1
  527. package/ts/array/UnionOfProps.ts +18 -18
  528. package/ts/array/drop.ts +2 -2
  529. package/ts/array/index.ts +19 -19
  530. package/ts/array/literalArray.ts +1 -1
  531. package/ts/assertion/assertType.ts +105 -105
  532. package/ts/assertion/index.ts +1 -1
  533. package/ts/binary/_binary.ts +1 -1
  534. package/ts/binary/index.ts +2 -2
  535. package/ts/class/index.ts +2 -2
  536. package/ts/class/isConstructor.ts +1 -1
  537. package/ts/function/index.ts +1 -1
  538. package/ts/functional/Maybe.ts +19 -19
  539. package/ts/functional/compose.ts +2 -2
  540. package/ts/functional/index.ts +3 -3
  541. package/ts/index.ts +19 -19
  542. package/ts/math/Abs.ts +1 -1
  543. package/ts/math/Add.ts +6 -6
  544. package/ts/math/Digit.ts +4 -4
  545. package/ts/math/GreaterThan.ts +6 -6
  546. package/ts/math/Max.ts +2 -2
  547. package/ts/math/Subtract.ts +6 -6
  548. package/ts/math/index.ts +8 -8
  549. package/ts/nodejs/index.ts +1 -1
  550. package/ts/nominal-types/Brand.ts +2 -2
  551. package/ts/nominal-types/Flavor.ts +32 -32
  552. package/ts/nominal-types/index.ts +3 -3
  553. package/ts/nominal-types/nominalMatch.ts +3 -3
  554. package/ts/object/ANotB.ts +21 -21
  555. package/ts/object/IsDisjoint.ts +12 -12
  556. package/ts/object/KeysWithDiffType.ts +3 -3
  557. package/ts/object/KnownKeys.ts +1 -1
  558. package/ts/object/OptionalKeys.ts +1 -1
  559. package/ts/object/Partial.ts +3 -3
  560. package/ts/object/RecursiveIntersect.ts +1 -1
  561. package/ts/object/RecursivePartial.ts +1 -1
  562. package/ts/object/RecursiveRequired.ts +1 -1
  563. package/ts/object/RequiredKeys.ts +2 -2
  564. package/ts/object/SpreadRecord.ts +6 -6
  565. package/ts/object/everyKey.ts +1 -1
  566. package/ts/object/facade.ts +39 -39
  567. package/ts/object/filterKey.ts +1 -1
  568. package/ts/object/findKey.ts +1 -1
  569. package/ts/object/forEachKey.ts +1 -1
  570. package/ts/object/getField.ts +1 -1
  571. package/ts/object/hasKey.ts +7 -7
  572. package/ts/object/hasProperty.ts +1 -1
  573. package/ts/object/index.ts +36 -36
  574. package/ts/object/mapKey.ts +1 -1
  575. package/ts/object/mapProperties.ts +3 -3
  576. package/ts/object/omit.ts +36 -36
  577. package/ts/object/pick.ts +35 -35
  578. package/ts/object/record.ts +3 -3
  579. package/ts/object/reduceKey.ts +1 -1
  580. package/ts/object/replaceProperty.ts +1 -1
  581. package/ts/object/someKey.ts +1 -1
  582. package/ts/object/split.ts +3 -3
  583. package/ts/object/typeOverrideIncompatible.ts +10 -10
  584. package/ts/predicates/CanAssign.ts +2 -2
  585. package/ts/predicates/index.ts +8 -8
  586. package/ts/predicates/isType.ts +30 -30
  587. package/ts/promise/PromiseValueMerge.ts +1 -1
  588. package/ts/promise/index.ts +4 -4
  589. package/ts/testing/index.ts +1 -1
  590. package/ts/testing/stub.ts +2 -2
  591. package/ts/utils/index.ts +4 -4
  592. package/ts/ComposableTypes.spec.ts +0 -29
  593. package/ts/JSONTypes.spec.ts +0 -43
  594. package/ts/array/CommonPropKeys.spec.ts +0 -20
  595. package/ts/array/Concat.spec.ts +0 -21
  596. package/ts/array/CreateTuple.spec.ts +0 -46
  597. package/ts/array/DropFirst.spec.ts +0 -21
  598. package/ts/array/DropLast.spec.ts +0 -21
  599. package/ts/array/DropMatch.spec.ts +0 -234
  600. package/ts/array/Filter.spec.ts +0 -107
  601. package/ts/array/FindFirst.spec.ts +0 -27
  602. package/ts/array/FindLast.spec.ts +0 -27
  603. package/ts/array/Head.spec.ts +0 -21
  604. package/ts/array/IntersectOfProps.spec.ts +0 -14
  605. package/ts/array/Last.spec.ts +0 -32
  606. package/ts/array/PadLeft.spec.ts +0 -26
  607. package/ts/array/Reverse.spec.ts +0 -17
  608. package/ts/array/Some.spec.ts +0 -79
  609. package/ts/array/Tail.spec.ts +0 -32
  610. package/ts/array/UnionOfProps.spec.ts +0 -14
  611. package/ts/array/UnionOfValues.spec.ts +0 -11
  612. package/ts/array/literalArray.spec.ts +0 -7
  613. package/ts/array/reduceWhile.spec.ts +0 -27
  614. package/ts/assertion/assertType.spec.ts +0 -507
  615. package/ts/binary/index.spec.ts +0 -28
  616. package/ts/class/AnyConstructor.spec.ts +0 -13
  617. package/ts/class/isConstructor.spec.ts +0 -35
  618. package/ts/function/AnyFunction.spec.ts +0 -21
  619. package/ts/functional/ChainFn.spec.ts +0 -7
  620. package/ts/functional/Maybe.spec.ts +0 -42
  621. package/ts/functional/compose.spec.ts +0 -32
  622. package/ts/index.spec.ts +0 -7
  623. package/ts/math/Abs.spec.ts +0 -14
  624. package/ts/math/Add.spec.ts +0 -82
  625. package/ts/math/Digit.spec.ts +0 -184
  626. package/ts/math/GreaterThan.spec.ts +0 -75
  627. package/ts/math/IsPositive.spec.ts +0 -15
  628. package/ts/math/IsWhole.spec.ts +0 -19
  629. package/ts/math/Max.spec.ts +0 -59
  630. package/ts/math/Subtract.spec.ts +0 -40
  631. package/ts/nodejs/isNodeError.spec.ts +0 -11
  632. package/ts/nominal-types/Brand.spec.ts +0 -43
  633. package/ts/nominal-types/Flavor.spec.ts +0 -51
  634. package/ts/nominal-types/nominalMatch.spec.ts +0 -54
  635. package/ts/object/ANotB.spec.ts +0 -78
  636. package/ts/object/ExcludePropType.spec.ts +0 -13
  637. package/ts/object/IsDisjoint.spec.ts +0 -25
  638. package/ts/object/IsRecord.spec.ts +0 -22
  639. package/ts/object/KeyTypes.spec.ts +0 -9
  640. package/ts/object/KeyofOptional.spec.ts +0 -8
  641. package/ts/object/KeysWithDiffType.spec.ts +0 -21
  642. package/ts/object/KnownKeys.spec.ts +0 -39
  643. package/ts/object/OptionalKeys.spec.ts +0 -23
  644. package/ts/object/Partial.spec.ts +0 -49
  645. package/ts/object/RecursiveIntersect.spec.ts +0 -39
  646. package/ts/object/RecursiveRequired.spec.ts +0 -57
  647. package/ts/object/Required.spec.ts +0 -29
  648. package/ts/object/RequiredKeys.spec.ts +0 -24
  649. package/ts/object/SpreadRecord.spec.ts +0 -14
  650. package/ts/object/ValueOf.spec.ts +0 -36
  651. package/ts/object/everyKey.spec.ts +0 -11
  652. package/ts/object/facade.spec.ts +0 -22
  653. package/ts/object/filterKey.spec.ts +0 -8
  654. package/ts/object/findKey.spec.ts +0 -8
  655. package/ts/object/forEachKey.spec.ts +0 -9
  656. package/ts/object/getField.spec.ts +0 -21
  657. package/ts/object/hasKey.spec.ts +0 -29
  658. package/ts/object/hasProperty.spec.ts +0 -15
  659. package/ts/object/mapKey.spec.ts +0 -8
  660. package/ts/object/mapProperties.spec.ts +0 -27
  661. package/ts/object/omit.spec.ts +0 -104
  662. package/ts/object/pick.spec.ts +0 -66
  663. package/ts/object/record.spec.ts +0 -54
  664. package/ts/object/reduceKey.spec.ts +0 -18
  665. package/ts/object/replaceProperty.spec.ts +0 -16
  666. package/ts/object/run.ts +0 -0
  667. package/ts/object/someKey.spec.ts +0 -6
  668. package/ts/object/split.spec.ts +0 -119
  669. package/ts/object/typeOverrideIncompatible.spec.ts +0 -24
  670. package/ts/predicates/CanAssign.spec.ts +0 -57
  671. package/ts/predicates/Equal.spec.ts +0 -71
  672. package/ts/predicates/If.spec.ts +0 -14
  673. package/ts/predicates/IsEmptyObject.spec.ts +0 -15
  674. package/ts/predicates/index.spec.ts +0 -73
  675. package/ts/predicates/isType.spec.ts +0 -106
  676. package/ts/predicates/logical.spec.ts +0 -59
  677. package/ts/promise/PromiseValue.spec.ts +0 -6
  678. package/ts/promise/PromiseValueMerge.spec.ts +0 -7
  679. package/ts/promise/isPromise.spec.ts +0 -26
  680. package/ts/promise/mapSeries.spec.ts +0 -12
  681. package/ts/testing/stub.spec.ts +0 -58
  682. package/ts/type-checker/.eslintrc.json +0 -7
  683. package/ts/type-checker/AnyType.ts +0 -13
  684. package/ts/type-checker/Boolean.ts +0 -34
  685. package/ts/type-checker/Tuple.spec.ts +0 -15
  686. package/ts/type-checker/Tuple.ts +0 -14
  687. package/ts/type-checker/buildTypes.spec.ts +0 -28
  688. package/ts/type-checker/index.ts +0 -0
  689. package/ts/type-checker/typeChecker.spec.ts +0 -14
  690. package/ts/type-checker/typeChecker.ts +0 -52
  691. package/ts/type-checker/types.ts +0 -19
  692. package/ts/types/.eslintrc.json +0 -7
  693. package/ts/types/AllType.ts +0 -31
  694. package/ts/types/Any.ts +0 -7
  695. package/ts/types/Array.ts +0 -43
  696. package/ts/types/BigInt.ts +0 -36
  697. package/ts/types/Boolean.ts +0 -36
  698. package/ts/types/Generate.ts +0 -48
  699. package/ts/types/Null.ts +0 -14
  700. package/ts/types/Number.ts +0 -56
  701. package/ts/types/Object.ts +0 -53
  702. package/ts/types/Record.ts +0 -25
  703. package/ts/types/String.ts +0 -56
  704. package/ts/types/Symbol.ts +0 -19
  705. package/ts/types/Tuple.ts +0 -50
  706. package/ts/types/Undefined.ts +0 -8
  707. package/ts/types/Union.ts +0 -46
  708. package/ts/types/Unknown.ts +0 -9
  709. package/ts/types/analyze.spec.ts +0 -979
  710. package/ts/types/analyze.ts +0 -170
  711. package/ts/types/check.spec.ts +0 -12
  712. package/ts/types/check.ts +0 -26
  713. package/ts/types/conform.spec.ts +0 -7
  714. package/ts/types/conform.ts +0 -27
  715. package/ts/types/getPlainAnalysisReport.spec.ts +0 -365
  716. package/ts/types/getPlainAnalysisReport.ts +0 -115
  717. package/ts/types/index.ts +0 -28
  718. package/ts/types/optional.ts +0 -30
  719. package/ts/types/required.ts +0 -30
  720. package/ts/types/satisfy.accept.ts +0 -39
  721. package/ts/types/satisfy.spec.ts +0 -600
  722. package/ts/types/satisfy.ts +0 -27
  723. package/ts/types/types.ts +0 -10
  724. package/ts/utils/as.spec.ts +0 -46
@@ -1,21 +0,0 @@
1
- import { getField } from '..'
2
-
3
- test('support undefined', () => {
4
- const sub: { a: number } | undefined = { a: 1 }
5
- expect(getField(sub, 'a')).toBe(1)
6
- })
7
-
8
- test('support null', () => {
9
- const sub: { a: number } | null = { a: 1 }
10
- expect(getField(sub, 'a')).toBe(1)
11
- })
12
-
13
- test('can specify default value', () => {
14
- const sub: { a?: number } = { a: undefined }
15
- expect(getField(sub, 'a', 2)).toBe(2)
16
- })
17
-
18
- test('get from union keys', () => {
19
- const sub: { a: number, b: string } | { a: number, c: string } = { a: 1, b: 'b' }
20
- expect(getField(sub, 'b')).toBe('b')
21
- })
@@ -1,29 +0,0 @@
1
- import { assertType, HasKey, hasKey } from '..'
2
-
3
- describe('HasKey<T, K>', () => {
4
- test('true if has key', () => {
5
- type Foo = { a: 1, b: 2 }
6
- assertType.isTrue(true as HasKey<Foo, 'a'>)
7
- })
8
-
9
- test('false if do not have key', () => {
10
- type Foo = { a: 1, b: 2 }
11
- assertType.isFalse(false as HasKey<Foo, 'c'>)
12
- })
13
- });
14
-
15
- describe('hasKey()', () => {
16
- test('true if has key', () => {
17
- const subject = { a: 1, b: 2 }
18
-
19
- expect(hasKey(subject, 'a')).toBeTruthy()
20
- expect(hasKey(subject, 'b')).toBeTruthy()
21
- expect(hasKey(subject, 'a', 'b')).toBeTruthy()
22
- })
23
- test('false if do not have key', () => {
24
- const subject = { a: 1, b: 2 }
25
-
26
- expect(hasKey(subject, 'c')).toBeFalsy()
27
- expect(hasKey(subject, 'a', 'c')).toBeFalsy()
28
- })
29
- });
@@ -1,15 +0,0 @@
1
- import { hasProperty } from '..'
2
-
3
- test('hasProperty', () => {
4
- type X = { name: string } & ({ a: 1 } | { b: 2 })
5
-
6
- const x: X = { name: 'n', a: 1 }
7
-
8
- if (hasProperty(x, 'a'))
9
- expect(x.a).toBe(1)
10
-
11
- const y: X = { name: 'n', b: 2 }
12
-
13
- if (hasProperty(y, 'b'))
14
- expect(y.b).toBe(2)
15
- })
@@ -1,8 +0,0 @@
1
- import a from 'assertron'
2
- import { mapKey } from '..'
3
-
4
- test('predicate key can be used as indexer of the subject', () => {
5
- const subject = { a: 1, b: 2, c: 3 }
6
- const actual = mapKey(subject, key => subject[key] + 1)
7
- a.satisfies(actual, [2, 3, 4])
8
- })
@@ -1,27 +0,0 @@
1
- import { mapProperties } from '..'
2
-
3
- test('basic usage', () => {
4
- const actual = mapProperties({ a: 1, b: 2 }, (v, k) => k + String((v * 2)))
5
- expect(actual).toEqual({ a: 'a2', b: 'b4' })
6
- })
7
-
8
- test('mixed type', () => {
9
- const actual = mapProperties({ a: 1, b: 'b' }, (v, k) => k + String(v))
10
- expect(actual).toEqual({ a: 'a1', b: 'bb' })
11
- })
12
-
13
- test('extract value from prop', () => {
14
- const actual = mapProperties({ a: { foo: 'x' }, b: { foo: 'y' } }, (v) => v.foo)
15
- expect(actual).toEqual({ a: 'x', b: 'y' })
16
- })
17
-
18
- test('parent props are not mapped', () => {
19
- class Boo {
20
- shared(v: number) { return v * 2 }
21
- own = (v: number) => v * 3
22
- }
23
- const boo = new Boo()
24
-
25
- const actual = mapProperties(boo, (v) => v(2))
26
- expect(actual).toEqual({ own: 6 })
27
- })
@@ -1,104 +0,0 @@
1
- import { assertType, Equal, Except, Omit, omit } from '..'
2
-
3
- describe('Omit', () => {
4
- test('work with primitive types', () => {
5
- type N = Omit<number, 'toFixed'>
6
- assertType.isFunction((() => ({})) as N['toExponential'])
7
- })
8
-
9
- test('Remove properties', () => {
10
- type Foo = {
11
- a: number,
12
- b: string,
13
- c: boolean,
14
- }
15
-
16
- type Actual = Omit<Foo, 'c'>
17
- const a: Actual = { a: 0, b: '' }
18
- assertType.isNumber(a.a)
19
- assertType.isString(a.b)
20
-
21
- type Revert = Omit<Foo, keyof Actual>
22
- const r: Revert = { c: false }
23
- assertType.isBoolean(r.c)
24
- })
25
-
26
- test('distributive omit', () => {
27
- type Action = InvokeAction | ReturnAction
28
-
29
- type InvokeAction = {
30
- type: 'invoke',
31
- id: string,
32
- payload: string[],
33
- }
34
-
35
- type ReturnAction = {
36
- type: 'return',
37
- id: string,
38
- payload: string,
39
- }
40
-
41
- const x: Omit<Action, 'id'> = { type: 'return', payload: '' }
42
-
43
- const actions: Action[] = []
44
-
45
- actions.push({ ...x, id: '1' })
46
- })
47
-
48
- test('distributive Omit with disjoined keys', () => {
49
- type Union = {
50
- type: 'A',
51
- foo: string,
52
- } | {
53
- type: 'B',
54
- foo: string,
55
- bar: string,
56
- }
57
- // eslint-disable-next-line @typescript-eslint/ban-types
58
- type Id<T> = {} & { [P in keyof T]: T[P] }
59
- let x: Id<Omit<Union, 'bar'>> = { type: 'A', foo: 'foo' }
60
- x = { type: 'B', foo: 'bar' }
61
- expect(x.foo).toBe('bar')
62
- })
63
-
64
- test('intersection types with generic', () => {
65
- type Foo = { a: string, b: string }
66
- function foo<T>(input: Omit<Foo & T, 'a'>): void {
67
- assertType.isString(input.b)
68
- }
69
- foo({ b: '1' })
70
- })
71
-
72
- test('omit properties from object', () => {
73
- const actual = omit({ a: 1, b: 2 }, 'a')
74
-
75
- expect(actual).toEqual({ b: 2 })
76
- })
77
-
78
- test('omit all', () => {
79
- const actual = omit({ a: 1 }, 'a')
80
-
81
- expect(actual).toEqual({})
82
- assertType.isTrue(true as Equal<keyof typeof actual, never>)
83
- })
84
- })
85
-
86
- describe('Except()', () => {
87
- test('Remove properties', () => {
88
- type Foo = {
89
- a: number,
90
- b: string,
91
- c: boolean,
92
- }
93
-
94
- type Actual = Except<Foo, 'c'>
95
- const a: Actual = { a: 0, b: '' }
96
- assertType.isNumber(a.a)
97
- assertType.isString(a.b)
98
-
99
- // tslint:disable-next-line: deprecation
100
- type Revert = Except<Foo, keyof Actual>
101
- const r: Revert = { c: false }
102
- assertType.isBoolean(r.c)
103
- })
104
- })
@@ -1,66 +0,0 @@
1
- import { assertType, canAssign, Equal, Pick, pick } from '..'
2
-
3
- test('pick properties from object', () => {
4
- const actual = pick({ a: 1, b: 2 }, 'a')
5
-
6
- expect(actual).toEqual({ a: 1 })
7
- })
8
-
9
- test('distributive pick', () => {
10
- type Action = InvokeAction | ReturnAction
11
-
12
- type InvokeAction = {
13
- type: 'invoke',
14
- id: string,
15
- payload: string[],
16
- }
17
-
18
- type ReturnAction = {
19
- type: 'return',
20
- id: string,
21
- payload: string,
22
- }
23
-
24
- const x: Pick<Action, 'type' | 'payload'> = { type: 'invoke', payload: [] }
25
-
26
- const actions: Action[] = []
27
-
28
- actions.push({ ...x, id: '1' })
29
- })
30
-
31
- test('distributive pick with disjoined keys', () => {
32
- type Union = {
33
- type: 'A',
34
- foo: string,
35
- } | {
36
- type: 'B',
37
- foo: string,
38
- bar: string,
39
- }
40
- type Id<T> = { [P in keyof T]: T[P] }
41
- let x: Id<Pick<Union, 'type' | 'bar'>> = { type: 'A' }
42
- x = { type: 'B', bar: 'bar' }
43
-
44
- expect(x.bar).toBe('bar')
45
- })
46
-
47
- test('intersection types with generic', () => {
48
- type Foo = { a: string, b: string }
49
- function foo<T>(input: Pick<Foo & T, 'a'>): void {
50
- assertType.isString(input.a)
51
- }
52
- foo({ a: '1' })
53
- })
54
-
55
- test('optional property remains optional', () => {
56
- type Foo = { a?: string, b: string }
57
- type A = Pick<Foo, 'a'>
58
- assertType.isTrue(canAssign<A>()({}))
59
- })
60
-
61
- test('pick never gets empty object', () => {
62
- type A = { a: number }
63
- type S = Pick<A, never>
64
- type K = keyof S
65
- assertType.isTrue(true as Equal<K, never>)
66
- })
@@ -1,54 +0,0 @@
1
- import { isType, KeyTypes, record } from '..'
2
-
3
- test('create an empty record with value default to unknown', () => {
4
- const a = record()
5
- a[1] = 2
6
- a['a'] = 'b'
7
- a[Symbol()] = true
8
- isType.equal<true, Record<KeyTypes, unknown>, typeof a>()
9
- })
10
-
11
- test('specify key and value types', () => {
12
- const a = record<string, number>()
13
- // even though the key type is string,
14
- // by default JavaScript will cast number index to string
15
- // so TypeScript also allows it.
16
- a[1] = 2
17
- a['a'] = 3
18
- isType.equal<true, Record<string, number>, typeof a>()
19
- })
20
-
21
- test('no prototype', () => {
22
- const a = record()
23
- expect(Object.getPrototypeOf(a)).toBeNull()
24
- })
25
-
26
- test('infer type from initial value, the key type is widen', () => {
27
- const stringRecord = record({ a: 1 })
28
- isType.equal<true, Record<string, number>, typeof stringRecord>()
29
-
30
- const numberRecord = record({ 1: 3 })
31
- isType.equal<true, Record<number, number>, typeof numberRecord>()
32
-
33
- const stringConstRecord = record({ a: 1 } as const)
34
- isType.equal<true, Record<string, 1>, typeof stringConstRecord>()
35
-
36
- const stringConstRecord2 = record({ a: 1 as const })
37
- isType.equal<true, Record<string, 1>, typeof stringConstRecord2>()
38
-
39
- const stringConstRecord3 = record({ a: 1 as const, b: 'b' })
40
- isType.equal<true, Record<string, 1 | string>, typeof stringConstRecord3>()
41
-
42
- const stringConstRecord4 = record({ a: 1 as const, b: 'b' as const })
43
- isType.equal<true, Record<string, 1 | 'b'>, typeof stringConstRecord4>()
44
- })
45
-
46
- test('no prototype with initial value', () => {
47
- const a = record({ a: 1 })
48
- expect(Object.getPrototypeOf(a)).toBeNull()
49
- })
50
-
51
- test('Object.keys() gets the keys of the initial value', () => {
52
- const a = record({ a: 1, b: 2 })
53
- expect(Object.keys(a)).toEqual(['a', 'b'])
54
- })
@@ -1,18 +0,0 @@
1
- import t from 'assert'
2
- import { reduceKey } from '..'
3
-
4
- test('predicate key can be used as indexer of the subject', () => {
5
- const subject = { a: 1, b: 2, c: 3 }
6
- const actual = reduceKey(subject, (p, k) => p += subject[k], 'a')
7
- t.strictEqual(actual, 'a123')
8
- })
9
-
10
- // currently k: never but it somehow works.
11
- // Can't find a way to get k to be a more reasonable type that works with `subject[k]`
12
- // So leaving it as is for now.
13
- test('key type is string if subject type is plain object', () => {
14
- // eslint-disable-next-line @typescript-eslint/ban-types
15
- const subject: {} = { a: 1 }
16
- const actual = reduceKey(subject, (p, k) => p += subject[k], 'a')
17
- t.strictEqual(actual, 'a1')
18
- })
@@ -1,16 +0,0 @@
1
- import { assertType, replaceProperty, ReplaceProperty } from '..'
2
-
3
- test('replaceProperty()', () => {
4
- const subject = { a: 1, b: 2 } as const
5
- const actual = replaceProperty(subject, 'a', () => 1)
6
- assertType<{ a: () => 1, b: 2 }>(actual)
7
- expect(actual.a()).toBe(1)
8
- })
9
-
10
- test('ReplaceProperty<>', () => {
11
- const subject = { a: 1, b: 2 }
12
-
13
- const actual = subject as ReplaceProperty<typeof subject, 'a', 1>
14
-
15
- assertType<{ a: 1, b: number }>(actual)
16
- })
package/ts/object/run.ts DELETED
File without changes
@@ -1,6 +0,0 @@
1
- import { someKey } from '..'
2
-
3
- test('predicate key can be used as indexer of the subject', () => {
4
- const subject = { a: 1, b: 2, c: 3 }
5
- expect(someKey(subject, key => subject[key] === 2)).toBe(true)
6
- })
@@ -1,119 +0,0 @@
1
- import { isType, split } from '..'
2
-
3
- const target = { a: 0, b: '', c: false }
4
-
5
- test('can use undefined as default', () => {
6
- const [{ a }] = split(target, { a: undefined })
7
-
8
- isType.equal<true, number, typeof a>()
9
- expect(a).toBe(0)
10
- })
11
-
12
- test('can specify default with the same type', () => {
13
- const [{ a }] = split(target, { a: 2 })
14
-
15
- isType.equal<true, typeof a, number>()
16
- expect(a).toBe(0)
17
- })
18
-
19
- test('specifying default removes undefined and null from the type', () => {
20
- type S = { a?: number | null, b: number }
21
- const s: S = { b: 2 }
22
-
23
- const [{ a }] = split(s, { a: 1 })
24
- expect(a).toBe(1)
25
-
26
- isType.equal<true, number, typeof a>()
27
- })
28
-
29
- test('can default with null', () => {
30
- const s: { a?: number | null } = {}
31
- const [{ a }] = split(s, { a: null })
32
-
33
- expect(a).toBe(null)
34
-
35
- isType.equal<true, number | null, typeof a>()
36
- })
37
-
38
- test('remove optional/undefined when default is provided', () => {
39
- interface S {
40
- variant?: 'abc' | 'def'
41
- }
42
- const s: S = {}
43
- const [a] = split(s, { variant: 'def' })
44
- isType.equal<true, 'abc' | 'def', typeof a.variant>()
45
- })
46
-
47
- test('keep undefined when default is undefined', () => {
48
- interface S {
49
- variant?: 'abc' | 'def'
50
- }
51
- const s: S = {}
52
- const [a] = split(s, { variant: undefined })
53
- isType.equal<true, 'abc' | 'def' | undefined, typeof a.variant>()
54
- })
55
-
56
-
57
- test('can default with false', () => {
58
- const s: { a?: number | boolean } = {}
59
- const [{ a }] = split(s, { a: false })
60
-
61
- expect(a).toBe(false)
62
-
63
- isType.equal<true, number | boolean, typeof a>()
64
- })
65
-
66
- test('can default with empty string', () => {
67
- const s: { a?: number | null | string } = {}
68
- const [{ a }] = split(s, { a: '' })
69
-
70
- expect(a).toBe('')
71
-
72
- isType.equal<true, number | string, typeof a>()
73
- })
74
-
75
- test('keep falsy value other than undefined and null', () => {
76
- expect(split({ a: '' }, { a: 'a' })[0].a).toBe('')
77
- expect(split({ a: false }, { a: true })[0].a).toBe(false)
78
-
79
- expect(split({ a: null as string | null }, { a: 'a' })[0].a).toBe('a')
80
- expect(split({ a: undefined as string | undefined }, { a: 'a' })[0].a).toBe('a')
81
- })
82
-
83
- test('can specify default as one of the intersect types', () => {
84
- const [a] = split({ a: undefined as number | string | undefined }, { a: '2' })
85
-
86
- isType.equal<true, typeof a, { a: number | string }>()
87
- expect(a).toEqual({ a: '2' })
88
- })
89
-
90
- test('get remaining props in the last entry', () => {
91
- const [, r] = split(target, { a: undefined })
92
-
93
- isType.equal<true, typeof r, { b: string, c: boolean }>()
94
- expect(r).toEqual({ b: '', c: false })
95
- })
96
-
97
- test('work with simple Record', () => {
98
- const [a] = split({} as Record<string, string>, { a: 'a' })
99
-
100
- isType.equal<true, typeof a, { a: string }>()
101
- expect(a).toEqual({ a: 'a' })
102
- })
103
-
104
- test('can specify multiple splitters', () => {
105
- const t = { r: 'r' } as { a?: string, b?: string, c?: string, r?: string }
106
- const [a, b, c, r] = split(t,
107
- { a: 'a' },
108
- { b: 'b' },
109
- { c: 'c' }
110
- )
111
- isType.equal<true, typeof a, { a: string }>()
112
- isType.equal<true, typeof b, { b: string }>()
113
- isType.equal<true, typeof c, { c: string }>()
114
- isType.equal<true, typeof r, { r?: string | undefined }>()
115
- expect(a).toEqual({ a: 'a' })
116
- expect(b).toEqual({ b: 'b' })
117
- expect(c).toEqual({ c: 'c' })
118
- expect(r).toEqual({ r: 'r' })
119
- })
@@ -1,24 +0,0 @@
1
- import { typeOverrideIncompatible } from '..'
2
-
3
- test('same type override has no property', () => {
4
- type A = { a: 1 }
5
- const transform = typeOverrideIncompatible<A>()
6
-
7
- // TODO: find a way to assert `override` has no property
8
- transform({ a: 1 }, {})
9
- })
10
-
11
- test('disjoint type override is A', () => {
12
- type A = { a: 1 }
13
- const transform = typeOverrideIncompatible<A>()
14
-
15
- transform({ b: 2 }, { a: 1 })
16
- })
17
-
18
- test('intersect type override is ANotB', () => {
19
- const a = { a: 1, b: 2 } as const
20
- const b = { b: 3, c: 3 } as const
21
- const transform = typeOverrideIncompatible<typeof a>()
22
-
23
- transform(b, { a: 1, b: 2 })
24
- })
@@ -1,57 +0,0 @@
1
- import { assertType, CanAssign, canAssign } from '..'
2
-
3
- describe('CanAssign<A, B>', () => {
4
- test('literal type to widen', () => {
5
- assertType.isTrue(true as CanAssign<1, number>)
6
- assertType.isTrue(true as CanAssign<1, 1>)
7
- assertType.isTrue(true as CanAssign<number, number>)
8
- assertType.isTrue(true as CanAssign<'a', string>)
9
- assertType.isTrue(true as CanAssign<'a', 'a'>)
10
- assertType.isTrue(true as CanAssign<string, string>)
11
- assertType.isTrue(true as CanAssign<false, boolean>)
12
- assertType.isTrue(true as CanAssign<true, boolean>)
13
- assertType.isTrue(true as CanAssign<boolean, boolean>)
14
- })
15
- test('base type to literal type fails', () => {
16
- assertType.isFalse(false as CanAssign<number, 1>)
17
- assertType.isFalse(false as CanAssign<string, 'a'>)
18
- assertType.isFalse(false as CanAssign<true, false>)
19
- assertType.isFalse(false as CanAssign<false, true>)
20
- assertType.isFalse(false as CanAssign<boolean, false>)
21
- assertType.isFalse(false as CanAssign<boolean, true>)
22
- })
23
- test('super set to sub set', () => {
24
- assertType.isTrue(true as CanAssign<{ a: string, b: number }, { a: string }>)
25
- })
26
- test('sub set to super set fail', () => {
27
- assertType.isFalse(false as CanAssign<{ a: string }, { a: string, b: number }>)
28
- })
29
- })
30
-
31
- describe('canAssign()', () => {
32
- describe('without subject', () => {
33
- test('returns a function that check type at compile time', () => {
34
- assertType.isTrue(canAssign<{ a: string }>()({ a: 'a' }))
35
- assertType.isTrue(canAssign<{ a: string }>()({ a: 'a', b: 'b' }))
36
-
37
- // fails at compile time
38
- // canAssign<{ a: string }>()({ a: 1 })
39
- })
40
- test('work with falsy value such as empty string', () => {
41
- const s = ''
42
- assertType.isTrue(canAssign<''>()(s))
43
- })
44
- test('work with undefined', () => {
45
- assertType.isTrue(canAssign<number | undefined>()(undefined))
46
- })
47
- test('canAssign false', () => {
48
- const t = canAssign<{ a: string }>(false)
49
- assertType.isTrue(t(undefined))
50
- assertType.isTrue(t({ a: 1 }))
51
-
52
- // these fails
53
- // t({ a: '' })
54
- // t({ a: '', b: '' })
55
- })
56
- })
57
- })
@@ -1,71 +0,0 @@
1
- import { assertType, Equal, NotEqual } from '..'
2
-
3
- describe('TypeEquals', () => {
4
- test('match', () => {
5
- assertType.isTrue(true as Equal<false, false>)
6
- })
7
-
8
- test('not match', () => {
9
- assertType.isFalse(false as Equal<string, number>)
10
- })
11
-
12
- test('literal is not equal to widen type', () => {
13
- assertType.isFalse(false as Equal<1, number>)
14
- assertType.isFalse(false as Equal<number, 1>)
15
- })
16
-
17
- test('super set and sub set are not equal', () => {
18
- assertType.isFalse(false as Equal<{ a: 1 }, { a: 1, b: 2 }>)
19
- assertType.isFalse(false as Equal<{ a: 1, b: 2 }, { a: 1 }>)
20
- })
21
-
22
- test('boolean', () => {
23
- assertType.isTrue(true as Equal<boolean, boolean>)
24
- assertType.isTrue(true as Equal<true, true>)
25
- assertType.isTrue(true as Equal<false, false>)
26
- assertType.isFalse(false as Equal<boolean, true>)
27
- assertType.isFalse(false as Equal<true, boolean>)
28
- assertType.isFalse(false as Equal<boolean, false>)
29
- assertType.isFalse(false as Equal<false, boolean>)
30
- assertType.isFalse(false as Equal<false, true>)
31
- assertType.isFalse(false as Equal<true, false>)
32
- })
33
-
34
- test('same type is true', () => {
35
- assertType.isTrue(true as Equal<{ a: 1 }, { a: 1 }>)
36
- })
37
-
38
- test('different type is false', () => {
39
- assertType.isFalse(false as Equal<{ a: 1 }, { b: 1 }>)
40
- })
41
-
42
- test('A subset of B is false', () => {
43
- assertType.isFalse(false as Equal<{ a: 1 }, { a: 1, b: 1 }>)
44
- })
45
-
46
- test('B subset of A is false', () => {
47
- assertType.isFalse(false as Equal<{ a: 1, b: 1 }, { a: 1 }>)
48
- })
49
-
50
- test('disjoin is false', () => {
51
- assertType.isFalse(false as Equal<{ b: 1 }, { a: 1 }>)
52
- })
53
-
54
- test('overlap is false', () => {
55
- assertType.isFalse(false as Equal<{ a: 1, b: 1 }, { a: 1, c: 2 }>)
56
- })
57
- })
58
-
59
- describe('TypeNotEquals', () => {
60
- test('boolean', () => {
61
- assertType.isFalse(false as NotEqual<boolean, boolean>)
62
- assertType.isFalse(false as NotEqual<true, true>)
63
- assertType.isFalse(false as NotEqual<false, false>)
64
- assertType.isTrue(true as NotEqual<boolean, true>)
65
- assertType.isTrue(true as NotEqual<true, boolean>)
66
- assertType.isTrue(true as NotEqual<boolean, false>)
67
- assertType.isTrue(true as NotEqual<false, boolean>)
68
- assertType.isTrue(true as NotEqual<false, true>)
69
- assertType.isTrue(true as NotEqual<true, false>)
70
- })
71
- })
@@ -1,14 +0,0 @@
1
- import { assertType, If, isType } from '..'
2
-
3
- test('true gets Then', () => {
4
- assertType<If<true, 2, 3>>(2)
5
- })
6
-
7
- test('false gets Else', () => {
8
- assertType<If<false, 2, 3>>(3)
9
- })
10
-
11
- test('Then defaults to true and Else defaults to false', () => {
12
- isType.t<If<true>>()
13
- isType.f<If<false>>()
14
- })
@@ -1,15 +0,0 @@
1
- /* eslint-disable @typescript-eslint/ban-types */
2
- import { IsEmptyObject } from '..'
3
- import { isType } from './isType'
4
-
5
- test('true for {}', () => {
6
- isType.t<IsEmptyObject<{}>>()
7
- })
8
- test('false for everything else', () => {
9
- isType.f<IsEmptyObject<undefined>>()
10
- isType.f<IsEmptyObject<false>>()
11
- isType.f<IsEmptyObject<0>>()
12
- isType.f<IsEmptyObject<''>>()
13
- isType.f<IsEmptyObject<{ a: 1 }>>()
14
- })
15
-