@mionjs/run-types 0.8.7 → 0.8.10

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 (396) hide show
  1. package/.dist/cjs/index.d.ts +1 -0
  2. package/.dist/cjs/index.d.ts.map +1 -0
  3. package/.dist/cjs/src/constants.d.ts +1 -0
  4. package/.dist/cjs/src/constants.d.ts.map +1 -0
  5. package/.dist/cjs/src/constants.functions.d.ts +1 -0
  6. package/.dist/cjs/src/constants.functions.d.ts.map +1 -0
  7. package/.dist/cjs/src/constants.kind.d.ts +1 -0
  8. package/.dist/cjs/src/constants.kind.d.ts.map +1 -0
  9. package/.dist/cjs/src/createRunType.cjs +3 -1
  10. package/.dist/cjs/src/createRunType.cjs.map +1 -1
  11. package/.dist/cjs/src/createRunType.d.ts +1 -0
  12. package/.dist/cjs/src/createRunType.d.ts.map +1 -0
  13. package/.dist/cjs/src/createRunTypeFunctions.d.ts +1 -0
  14. package/.dist/cjs/src/createRunTypeFunctions.d.ts.map +1 -0
  15. package/.dist/cjs/src/formats.runtype.d.ts +1 -0
  16. package/.dist/cjs/src/formats.runtype.d.ts.map +1 -0
  17. package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
  18. package/.dist/cjs/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
  19. package/.dist/cjs/src/jitCompilers/binary/fromBinary.cjs +1 -1
  20. package/.dist/cjs/src/jitCompilers/binary/fromBinary.cjs.map +1 -1
  21. package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts +1 -0
  22. package/.dist/cjs/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
  23. package/.dist/cjs/src/jitCompilers/binary/toBinary.cjs +1 -1
  24. package/.dist/cjs/src/jitCompilers/binary/toBinary.cjs.map +1 -1
  25. package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts +1 -0
  26. package/.dist/cjs/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
  27. package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts +1 -0
  28. package/.dist/cjs/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
  29. package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
  30. package/.dist/cjs/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
  31. package/.dist/cjs/src/jitCompilers/json/stringifyJson.cjs +1 -1
  32. package/.dist/cjs/src/jitCompilers/json/stringifyJson.cjs.map +1 -1
  33. package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts +1 -0
  34. package/.dist/cjs/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
  35. package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
  36. package/.dist/cjs/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
  37. package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts +1 -0
  38. package/.dist/cjs/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
  39. package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts +1 -0
  40. package/.dist/cjs/src/lib/baseRunTypeFormat.d.ts.map +1 -0
  41. package/.dist/cjs/src/lib/baseRunTypes.d.ts +1 -0
  42. package/.dist/cjs/src/lib/baseRunTypes.d.ts.map +1 -0
  43. package/.dist/cjs/src/lib/createJitFunction.d.ts +1 -0
  44. package/.dist/cjs/src/lib/createJitFunction.d.ts.map +1 -0
  45. package/.dist/cjs/src/lib/dkProxy.d.ts +1 -0
  46. package/.dist/cjs/src/lib/dkProxy.d.ts.map +1 -0
  47. package/.dist/cjs/src/lib/formats.d.ts +1 -0
  48. package/.dist/cjs/src/lib/formats.d.ts.map +1 -0
  49. package/.dist/cjs/src/lib/guards.d.ts +1 -0
  50. package/.dist/cjs/src/lib/guards.d.ts.map +1 -0
  51. package/.dist/cjs/src/lib/jitFnCompiler.d.ts +1 -0
  52. package/.dist/cjs/src/lib/jitFnCompiler.d.ts.map +1 -0
  53. package/.dist/cjs/src/lib/jitFnsRegistry.d.ts +1 -0
  54. package/.dist/cjs/src/lib/jitFnsRegistry.d.ts.map +1 -0
  55. package/.dist/cjs/src/lib/typeId.d.ts +1 -0
  56. package/.dist/cjs/src/lib/typeId.d.ts.map +1 -0
  57. package/.dist/cjs/src/lib/utils.d.ts +1 -0
  58. package/.dist/cjs/src/lib/utils.d.ts.map +1 -0
  59. package/.dist/cjs/src/mocking/constants.mock.d.ts +1 -0
  60. package/.dist/cjs/src/mocking/constants.mock.d.ts.map +1 -0
  61. package/.dist/cjs/src/mocking/mockRegistry.d.ts +1 -0
  62. package/.dist/cjs/src/mocking/mockRegistry.d.ts.map +1 -0
  63. package/.dist/cjs/src/mocking/mockType.cjs +46 -1
  64. package/.dist/cjs/src/mocking/mockType.cjs.map +1 -1
  65. package/.dist/cjs/src/mocking/mockType.d.ts +1 -0
  66. package/.dist/cjs/src/mocking/mockType.d.ts.map +1 -0
  67. package/.dist/cjs/src/mocking/mockUtils.d.ts +1 -0
  68. package/.dist/cjs/src/mocking/mockUtils.d.ts.map +1 -0
  69. package/.dist/cjs/src/nodes/atomic/any.d.ts +1 -0
  70. package/.dist/cjs/src/nodes/atomic/any.d.ts.map +1 -0
  71. package/.dist/cjs/src/nodes/atomic/bigInt.d.ts +1 -0
  72. package/.dist/cjs/src/nodes/atomic/bigInt.d.ts.map +1 -0
  73. package/.dist/cjs/src/nodes/atomic/boolean.d.ts +1 -0
  74. package/.dist/cjs/src/nodes/atomic/boolean.d.ts.map +1 -0
  75. package/.dist/cjs/src/nodes/atomic/date.d.ts +1 -0
  76. package/.dist/cjs/src/nodes/atomic/date.d.ts.map +1 -0
  77. package/.dist/cjs/src/nodes/atomic/enum.d.ts +1 -0
  78. package/.dist/cjs/src/nodes/atomic/enum.d.ts.map +1 -0
  79. package/.dist/cjs/src/nodes/atomic/enumMember.d.ts +1 -0
  80. package/.dist/cjs/src/nodes/atomic/enumMember.d.ts.map +1 -0
  81. package/.dist/cjs/src/nodes/atomic/literal.d.ts +1 -0
  82. package/.dist/cjs/src/nodes/atomic/literal.d.ts.map +1 -0
  83. package/.dist/cjs/src/nodes/atomic/never.d.ts +1 -0
  84. package/.dist/cjs/src/nodes/atomic/never.d.ts.map +1 -0
  85. package/.dist/cjs/src/nodes/atomic/null.d.ts +1 -0
  86. package/.dist/cjs/src/nodes/atomic/null.d.ts.map +1 -0
  87. package/.dist/cjs/src/nodes/atomic/number.d.ts +1 -0
  88. package/.dist/cjs/src/nodes/atomic/number.d.ts.map +1 -0
  89. package/.dist/cjs/src/nodes/atomic/object.d.ts +1 -0
  90. package/.dist/cjs/src/nodes/atomic/object.d.ts.map +1 -0
  91. package/.dist/cjs/src/nodes/atomic/regexp.d.ts +1 -0
  92. package/.dist/cjs/src/nodes/atomic/regexp.d.ts.map +1 -0
  93. package/.dist/cjs/src/nodes/atomic/string.d.ts +1 -0
  94. package/.dist/cjs/src/nodes/atomic/string.d.ts.map +1 -0
  95. package/.dist/cjs/src/nodes/atomic/symbol.d.ts +1 -0
  96. package/.dist/cjs/src/nodes/atomic/symbol.d.ts.map +1 -0
  97. package/.dist/cjs/src/nodes/atomic/undefined.d.ts +1 -0
  98. package/.dist/cjs/src/nodes/atomic/undefined.d.ts.map +1 -0
  99. package/.dist/cjs/src/nodes/atomic/unknown.d.ts +1 -0
  100. package/.dist/cjs/src/nodes/atomic/unknown.d.ts.map +1 -0
  101. package/.dist/cjs/src/nodes/atomic/void.d.ts +1 -0
  102. package/.dist/cjs/src/nodes/atomic/void.d.ts.map +1 -0
  103. package/.dist/cjs/src/nodes/collection/class.d.ts +1 -0
  104. package/.dist/cjs/src/nodes/collection/class.d.ts.map +1 -0
  105. package/.dist/cjs/src/nodes/collection/functionParams.d.ts +1 -0
  106. package/.dist/cjs/src/nodes/collection/functionParams.d.ts.map +1 -0
  107. package/.dist/cjs/src/nodes/collection/interface.d.ts +1 -0
  108. package/.dist/cjs/src/nodes/collection/interface.d.ts.map +1 -0
  109. package/.dist/cjs/src/nodes/collection/intersection.d.ts +1 -0
  110. package/.dist/cjs/src/nodes/collection/intersection.d.ts.map +1 -0
  111. package/.dist/cjs/src/nodes/collection/templateLiteral.cjs +73 -0
  112. package/.dist/cjs/src/nodes/collection/templateLiteral.cjs.map +1 -0
  113. package/.dist/cjs/src/nodes/collection/templateLiteral.d.ts +16 -0
  114. package/.dist/cjs/src/nodes/collection/templateLiteral.d.ts.map +1 -0
  115. package/.dist/cjs/src/nodes/collection/tuple.d.ts +1 -0
  116. package/.dist/cjs/src/nodes/collection/tuple.d.ts.map +1 -0
  117. package/.dist/cjs/src/nodes/collection/union.d.ts +1 -0
  118. package/.dist/cjs/src/nodes/collection/union.d.ts.map +1 -0
  119. package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts +1 -0
  120. package/.dist/cjs/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
  121. package/.dist/cjs/src/nodes/function/function.d.ts +1 -0
  122. package/.dist/cjs/src/nodes/function/function.d.ts.map +1 -0
  123. package/.dist/cjs/src/nodes/member/array.d.ts +1 -0
  124. package/.dist/cjs/src/nodes/member/array.d.ts.map +1 -0
  125. package/.dist/cjs/src/nodes/member/callSignature.d.ts +1 -0
  126. package/.dist/cjs/src/nodes/member/callSignature.d.ts.map +1 -0
  127. package/.dist/cjs/src/nodes/member/genericMember.d.ts +1 -0
  128. package/.dist/cjs/src/nodes/member/genericMember.d.ts.map +1 -0
  129. package/.dist/cjs/src/nodes/member/indexProperty.cjs +69 -22
  130. package/.dist/cjs/src/nodes/member/indexProperty.cjs.map +1 -1
  131. package/.dist/cjs/src/nodes/member/indexProperty.d.ts +2 -0
  132. package/.dist/cjs/src/nodes/member/indexProperty.d.ts.map +1 -0
  133. package/.dist/cjs/src/nodes/member/method.d.ts +1 -0
  134. package/.dist/cjs/src/nodes/member/method.d.ts.map +1 -0
  135. package/.dist/cjs/src/nodes/member/methodSignature.d.ts +1 -0
  136. package/.dist/cjs/src/nodes/member/methodSignature.d.ts.map +1 -0
  137. package/.dist/cjs/src/nodes/member/param.d.ts +1 -0
  138. package/.dist/cjs/src/nodes/member/param.d.ts.map +1 -0
  139. package/.dist/cjs/src/nodes/member/property.d.ts +1 -0
  140. package/.dist/cjs/src/nodes/member/property.d.ts.map +1 -0
  141. package/.dist/cjs/src/nodes/member/restParams.d.ts +1 -0
  142. package/.dist/cjs/src/nodes/member/restParams.d.ts.map +1 -0
  143. package/.dist/cjs/src/nodes/member/tupleMember.d.ts +1 -0
  144. package/.dist/cjs/src/nodes/member/tupleMember.d.ts.map +1 -0
  145. package/.dist/cjs/src/nodes/native/Iterable.d.ts +1 -0
  146. package/.dist/cjs/src/nodes/native/Iterable.d.ts.map +1 -0
  147. package/.dist/cjs/src/nodes/native/map.d.ts +1 -0
  148. package/.dist/cjs/src/nodes/native/map.d.ts.map +1 -0
  149. package/.dist/cjs/src/nodes/native/nonSerializable.d.ts +1 -0
  150. package/.dist/cjs/src/nodes/native/nonSerializable.d.ts.map +1 -0
  151. package/.dist/cjs/src/nodes/native/promise.d.ts +1 -0
  152. package/.dist/cjs/src/nodes/native/promise.d.ts.map +1 -0
  153. package/.dist/cjs/src/nodes/native/set.d.ts +1 -0
  154. package/.dist/cjs/src/nodes/native/set.d.ts.map +1 -0
  155. package/.dist/cjs/src/run-types-pure-fns.d.ts +1 -0
  156. package/.dist/cjs/src/run-types-pure-fns.d.ts.map +1 -0
  157. package/.dist/cjs/src/types.d.ts +1 -0
  158. package/.dist/cjs/src/types.d.ts.map +1 -0
  159. package/.dist/esm/index.d.ts +1 -0
  160. package/.dist/esm/index.d.ts.map +1 -0
  161. package/.dist/esm/src/constants.d.ts +1 -0
  162. package/.dist/esm/src/constants.d.ts.map +1 -0
  163. package/.dist/esm/src/constants.functions.d.ts +1 -0
  164. package/.dist/esm/src/constants.functions.d.ts.map +1 -0
  165. package/.dist/esm/src/constants.kind.d.ts +1 -0
  166. package/.dist/esm/src/constants.kind.d.ts.map +1 -0
  167. package/.dist/esm/src/createRunType.d.ts +1 -0
  168. package/.dist/esm/src/createRunType.d.ts.map +1 -0
  169. package/.dist/esm/src/createRunType.js +3 -1
  170. package/.dist/esm/src/createRunType.js.map +1 -1
  171. package/.dist/esm/src/createRunTypeFunctions.d.ts +1 -0
  172. package/.dist/esm/src/createRunTypeFunctions.d.ts.map +1 -0
  173. package/.dist/esm/src/formats.runtype.d.ts +1 -0
  174. package/.dist/esm/src/formats.runtype.d.ts.map +1 -0
  175. package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts +1 -0
  176. package/.dist/esm/src/jitCompilers/binary/binarySpec/binaryHelpers.d.ts.map +1 -0
  177. package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts +1 -0
  178. package/.dist/esm/src/jitCompilers/binary/fromBinary.d.ts.map +1 -0
  179. package/.dist/esm/src/jitCompilers/binary/fromBinary.js +1 -1
  180. package/.dist/esm/src/jitCompilers/binary/fromBinary.js.map +1 -1
  181. package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts +1 -0
  182. package/.dist/esm/src/jitCompilers/binary/toBinary.d.ts.map +1 -0
  183. package/.dist/esm/src/jitCompilers/binary/toBinary.js +1 -1
  184. package/.dist/esm/src/jitCompilers/binary/toBinary.js.map +1 -1
  185. package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts +1 -0
  186. package/.dist/esm/src/jitCompilers/equalsHelpers.d.ts.map +1 -0
  187. package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts +1 -0
  188. package/.dist/esm/src/jitCompilers/json/jsonSpec/jsonHelpers.d.ts.map +1 -0
  189. package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts +1 -0
  190. package/.dist/esm/src/jitCompilers/json/stringifyJson.d.ts.map +1 -0
  191. package/.dist/esm/src/jitCompilers/json/stringifyJson.js +1 -1
  192. package/.dist/esm/src/jitCompilers/json/stringifyJson.js.map +1 -1
  193. package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts +1 -0
  194. package/.dist/esm/src/jitCompilers/json/stringifySpec/stringifyHelpers.d.ts.map +1 -0
  195. package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts +1 -0
  196. package/.dist/esm/src/jitCompilers/json/toJsCode.d.ts.map +1 -0
  197. package/.dist/esm/src/lib/baseRunTypeFormat.d.ts +1 -0
  198. package/.dist/esm/src/lib/baseRunTypeFormat.d.ts.map +1 -0
  199. package/.dist/esm/src/lib/baseRunTypes.d.ts +1 -0
  200. package/.dist/esm/src/lib/baseRunTypes.d.ts.map +1 -0
  201. package/.dist/esm/src/lib/createJitFunction.d.ts +1 -0
  202. package/.dist/esm/src/lib/createJitFunction.d.ts.map +1 -0
  203. package/.dist/esm/src/lib/dkProxy.d.ts +1 -0
  204. package/.dist/esm/src/lib/dkProxy.d.ts.map +1 -0
  205. package/.dist/esm/src/lib/formats.d.ts +1 -0
  206. package/.dist/esm/src/lib/formats.d.ts.map +1 -0
  207. package/.dist/esm/src/lib/guards.d.ts +1 -0
  208. package/.dist/esm/src/lib/guards.d.ts.map +1 -0
  209. package/.dist/esm/src/lib/jitFnCompiler.d.ts +1 -0
  210. package/.dist/esm/src/lib/jitFnCompiler.d.ts.map +1 -0
  211. package/.dist/esm/src/lib/jitFnsRegistry.d.ts +1 -0
  212. package/.dist/esm/src/lib/jitFnsRegistry.d.ts.map +1 -0
  213. package/.dist/esm/src/lib/typeId.d.ts +1 -0
  214. package/.dist/esm/src/lib/typeId.d.ts.map +1 -0
  215. package/.dist/esm/src/lib/utils.d.ts +1 -0
  216. package/.dist/esm/src/lib/utils.d.ts.map +1 -0
  217. package/.dist/esm/src/mocking/constants.mock.d.ts +1 -0
  218. package/.dist/esm/src/mocking/constants.mock.d.ts.map +1 -0
  219. package/.dist/esm/src/mocking/mockRegistry.d.ts +1 -0
  220. package/.dist/esm/src/mocking/mockRegistry.d.ts.map +1 -0
  221. package/.dist/esm/src/mocking/mockType.d.ts +1 -0
  222. package/.dist/esm/src/mocking/mockType.d.ts.map +1 -0
  223. package/.dist/esm/src/mocking/mockType.js +47 -2
  224. package/.dist/esm/src/mocking/mockType.js.map +1 -1
  225. package/.dist/esm/src/mocking/mockUtils.d.ts +1 -0
  226. package/.dist/esm/src/mocking/mockUtils.d.ts.map +1 -0
  227. package/.dist/esm/src/mocking/mockUtils.js +1 -1
  228. package/.dist/esm/src/nodes/atomic/any.d.ts +1 -0
  229. package/.dist/esm/src/nodes/atomic/any.d.ts.map +1 -0
  230. package/.dist/esm/src/nodes/atomic/bigInt.d.ts +1 -0
  231. package/.dist/esm/src/nodes/atomic/bigInt.d.ts.map +1 -0
  232. package/.dist/esm/src/nodes/atomic/boolean.d.ts +1 -0
  233. package/.dist/esm/src/nodes/atomic/boolean.d.ts.map +1 -0
  234. package/.dist/esm/src/nodes/atomic/date.d.ts +1 -0
  235. package/.dist/esm/src/nodes/atomic/date.d.ts.map +1 -0
  236. package/.dist/esm/src/nodes/atomic/enum.d.ts +1 -0
  237. package/.dist/esm/src/nodes/atomic/enum.d.ts.map +1 -0
  238. package/.dist/esm/src/nodes/atomic/enumMember.d.ts +1 -0
  239. package/.dist/esm/src/nodes/atomic/enumMember.d.ts.map +1 -0
  240. package/.dist/esm/src/nodes/atomic/literal.d.ts +1 -0
  241. package/.dist/esm/src/nodes/atomic/literal.d.ts.map +1 -0
  242. package/.dist/esm/src/nodes/atomic/never.d.ts +1 -0
  243. package/.dist/esm/src/nodes/atomic/never.d.ts.map +1 -0
  244. package/.dist/esm/src/nodes/atomic/null.d.ts +1 -0
  245. package/.dist/esm/src/nodes/atomic/null.d.ts.map +1 -0
  246. package/.dist/esm/src/nodes/atomic/number.d.ts +1 -0
  247. package/.dist/esm/src/nodes/atomic/number.d.ts.map +1 -0
  248. package/.dist/esm/src/nodes/atomic/object.d.ts +1 -0
  249. package/.dist/esm/src/nodes/atomic/object.d.ts.map +1 -0
  250. package/.dist/esm/src/nodes/atomic/regexp.d.ts +1 -0
  251. package/.dist/esm/src/nodes/atomic/regexp.d.ts.map +1 -0
  252. package/.dist/esm/src/nodes/atomic/string.d.ts +1 -0
  253. package/.dist/esm/src/nodes/atomic/string.d.ts.map +1 -0
  254. package/.dist/esm/src/nodes/atomic/symbol.d.ts +1 -0
  255. package/.dist/esm/src/nodes/atomic/symbol.d.ts.map +1 -0
  256. package/.dist/esm/src/nodes/atomic/undefined.d.ts +1 -0
  257. package/.dist/esm/src/nodes/atomic/undefined.d.ts.map +1 -0
  258. package/.dist/esm/src/nodes/atomic/unknown.d.ts +1 -0
  259. package/.dist/esm/src/nodes/atomic/unknown.d.ts.map +1 -0
  260. package/.dist/esm/src/nodes/atomic/void.d.ts +1 -0
  261. package/.dist/esm/src/nodes/atomic/void.d.ts.map +1 -0
  262. package/.dist/esm/src/nodes/collection/class.d.ts +1 -0
  263. package/.dist/esm/src/nodes/collection/class.d.ts.map +1 -0
  264. package/.dist/esm/src/nodes/collection/functionParams.d.ts +1 -0
  265. package/.dist/esm/src/nodes/collection/functionParams.d.ts.map +1 -0
  266. package/.dist/esm/src/nodes/collection/interface.d.ts +1 -0
  267. package/.dist/esm/src/nodes/collection/interface.d.ts.map +1 -0
  268. package/.dist/esm/src/nodes/collection/intersection.d.ts +1 -0
  269. package/.dist/esm/src/nodes/collection/intersection.d.ts.map +1 -0
  270. package/.dist/esm/src/nodes/collection/templateLiteral.d.ts +16 -0
  271. package/.dist/esm/src/nodes/collection/templateLiteral.d.ts.map +1 -0
  272. package/.dist/esm/src/nodes/collection/templateLiteral.js +73 -0
  273. package/.dist/esm/src/nodes/collection/templateLiteral.js.map +1 -0
  274. package/.dist/esm/src/nodes/collection/tuple.d.ts +1 -0
  275. package/.dist/esm/src/nodes/collection/tuple.d.ts.map +1 -0
  276. package/.dist/esm/src/nodes/collection/union.d.ts +1 -0
  277. package/.dist/esm/src/nodes/collection/union.d.ts.map +1 -0
  278. package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts +1 -0
  279. package/.dist/esm/src/nodes/collection/unionDiscriminator.d.ts.map +1 -0
  280. package/.dist/esm/src/nodes/function/function.d.ts +1 -0
  281. package/.dist/esm/src/nodes/function/function.d.ts.map +1 -0
  282. package/.dist/esm/src/nodes/member/array.d.ts +1 -0
  283. package/.dist/esm/src/nodes/member/array.d.ts.map +1 -0
  284. package/.dist/esm/src/nodes/member/callSignature.d.ts +1 -0
  285. package/.dist/esm/src/nodes/member/callSignature.d.ts.map +1 -0
  286. package/.dist/esm/src/nodes/member/genericMember.d.ts +1 -0
  287. package/.dist/esm/src/nodes/member/genericMember.d.ts.map +1 -0
  288. package/.dist/esm/src/nodes/member/indexProperty.d.ts +2 -0
  289. package/.dist/esm/src/nodes/member/indexProperty.d.ts.map +1 -0
  290. package/.dist/esm/src/nodes/member/indexProperty.js +70 -23
  291. package/.dist/esm/src/nodes/member/indexProperty.js.map +1 -1
  292. package/.dist/esm/src/nodes/member/method.d.ts +1 -0
  293. package/.dist/esm/src/nodes/member/method.d.ts.map +1 -0
  294. package/.dist/esm/src/nodes/member/methodSignature.d.ts +1 -0
  295. package/.dist/esm/src/nodes/member/methodSignature.d.ts.map +1 -0
  296. package/.dist/esm/src/nodes/member/param.d.ts +1 -0
  297. package/.dist/esm/src/nodes/member/param.d.ts.map +1 -0
  298. package/.dist/esm/src/nodes/member/property.d.ts +1 -0
  299. package/.dist/esm/src/nodes/member/property.d.ts.map +1 -0
  300. package/.dist/esm/src/nodes/member/restParams.d.ts +1 -0
  301. package/.dist/esm/src/nodes/member/restParams.d.ts.map +1 -0
  302. package/.dist/esm/src/nodes/member/tupleMember.d.ts +1 -0
  303. package/.dist/esm/src/nodes/member/tupleMember.d.ts.map +1 -0
  304. package/.dist/esm/src/nodes/native/Iterable.d.ts +1 -0
  305. package/.dist/esm/src/nodes/native/Iterable.d.ts.map +1 -0
  306. package/.dist/esm/src/nodes/native/map.d.ts +1 -0
  307. package/.dist/esm/src/nodes/native/map.d.ts.map +1 -0
  308. package/.dist/esm/src/nodes/native/nonSerializable.d.ts +1 -0
  309. package/.dist/esm/src/nodes/native/nonSerializable.d.ts.map +1 -0
  310. package/.dist/esm/src/nodes/native/promise.d.ts +1 -0
  311. package/.dist/esm/src/nodes/native/promise.d.ts.map +1 -0
  312. package/.dist/esm/src/nodes/native/set.d.ts +1 -0
  313. package/.dist/esm/src/nodes/native/set.d.ts.map +1 -0
  314. package/.dist/esm/src/run-types-pure-fns.d.ts +1 -0
  315. package/.dist/esm/src/run-types-pure-fns.d.ts.map +1 -0
  316. package/.dist/esm/src/types.d.ts +1 -0
  317. package/.dist/esm/src/types.d.ts.map +1 -0
  318. package/index.ts +70 -0
  319. package/package.json +8 -4
  320. package/src/constants.functions.ts +196 -0
  321. package/src/constants.kind.ts +76 -0
  322. package/src/constants.ts +85 -0
  323. package/src/createRunType.ts +322 -0
  324. package/src/createRunTypeFunctions.ts +93 -0
  325. package/src/formats.runtype.ts +35 -0
  326. package/src/jitCompilers/binary/binarySPEC.md +138 -0
  327. package/src/jitCompilers/binary/binarySpec/binaryHelpers.ts +118 -0
  328. package/src/jitCompilers/binary/fromBinary.ts +493 -0
  329. package/src/jitCompilers/binary/toBinary.ts +436 -0
  330. package/src/jitCompilers/equalsHelpers.ts +62 -0
  331. package/src/jitCompilers/json/jsonSpec/jsonHelpers.ts +64 -0
  332. package/src/jitCompilers/json/stringifyJson.ts +476 -0
  333. package/src/jitCompilers/json/stringifySpec/stringifyHelpers.ts +59 -0
  334. package/src/jitCompilers/json/toJsCode.ts +182 -0
  335. package/src/jitCompilers/serialization-suite.ts +1689 -0
  336. package/src/jitCompilers/xyz-Template/fromXYZ.ts +212 -0
  337. package/src/jitCompilers/xyz-Template/toXYZ.ts +217 -0
  338. package/src/jitCompilers/xyz-Template/xyzReadme.md +6 -0
  339. package/src/jitCompilers/xyz-Template/xyzSpec/xyzHelpers.ts +66 -0
  340. package/src/lib/baseRunTypeFormat.ts +320 -0
  341. package/src/lib/baseRunTypes.ts +367 -0
  342. package/src/lib/createJitFunction.ts +87 -0
  343. package/src/lib/dkProxy.ts +47 -0
  344. package/src/lib/formats.ts +144 -0
  345. package/src/lib/guards.ts +290 -0
  346. package/src/lib/jitFnCompiler.ts +783 -0
  347. package/src/lib/jitFnsRegistry.ts +53 -0
  348. package/src/lib/typeId.ts +225 -0
  349. package/src/lib/utils.ts +402 -0
  350. package/src/mocking/constants.mock.ts +87 -0
  351. package/src/mocking/mockRegistry.ts +20 -0
  352. package/src/mocking/mockType.ts +409 -0
  353. package/src/mocking/mockUtils.ts +82 -0
  354. package/src/nodes/atomic/any.ts +22 -0
  355. package/src/nodes/atomic/bigInt.ts +26 -0
  356. package/src/nodes/atomic/boolean.ts +26 -0
  357. package/src/nodes/atomic/date.ts +26 -0
  358. package/src/nodes/atomic/enum.ts +23 -0
  359. package/src/nodes/atomic/enumMember.ts +29 -0
  360. package/src/nodes/atomic/literal.ts +125 -0
  361. package/src/nodes/atomic/never.ts +26 -0
  362. package/src/nodes/atomic/null.ts +26 -0
  363. package/src/nodes/atomic/number.ts +26 -0
  364. package/src/nodes/atomic/object.ts +20 -0
  365. package/src/nodes/atomic/regexp.ts +29 -0
  366. package/src/nodes/atomic/string.ts +20 -0
  367. package/src/nodes/atomic/symbol.ts +31 -0
  368. package/src/nodes/atomic/undefined.ts +23 -0
  369. package/src/nodes/atomic/unknown.ts +10 -0
  370. package/src/nodes/atomic/void.ts +26 -0
  371. package/src/nodes/collection/class.ts +36 -0
  372. package/src/nodes/collection/functionParams.ts +42 -0
  373. package/src/nodes/collection/interface.ts +300 -0
  374. package/src/nodes/collection/intersection.ts +30 -0
  375. package/src/nodes/collection/templateLiteral.ts +87 -0
  376. package/src/nodes/collection/tuple.ts +80 -0
  377. package/src/nodes/collection/union.ts +205 -0
  378. package/src/nodes/collection/unionDiscriminator.ts +259 -0
  379. package/src/nodes/function/function.ts +166 -0
  380. package/src/nodes/member/array.ts +150 -0
  381. package/src/nodes/member/callSignature.ts +34 -0
  382. package/src/nodes/member/genericMember.ts +63 -0
  383. package/src/nodes/member/indexProperty.ts +174 -0
  384. package/src/nodes/member/method.ts +30 -0
  385. package/src/nodes/member/methodSignature.ts +31 -0
  386. package/src/nodes/member/param.ts +22 -0
  387. package/src/nodes/member/property.ts +75 -0
  388. package/src/nodes/member/restParams.ts +22 -0
  389. package/src/nodes/member/tupleMember.ts +93 -0
  390. package/src/nodes/native/Iterable.ts +153 -0
  391. package/src/nodes/native/map.ts +91 -0
  392. package/src/nodes/native/nonSerializable.ts +42 -0
  393. package/src/nodes/native/promise.ts +43 -0
  394. package/src/nodes/native/set.ts +56 -0
  395. package/src/run-types-pure-fns.ts +116 -0
  396. package/src/types.ts +206 -0
@@ -0,0 +1,1689 @@
1
+ /* ########
2
+ * 2025 mion
3
+ * Author: Ma-jerez
4
+ * License: MIT
5
+ * The software is provided "as is", without warranty of any kind.
6
+ * ######## */
7
+
8
+ import {DataOnly, getJitUtils, RpcError} from '@mionjs/core';
9
+ import {reflectFunction, runType} from '../createRunType.ts';
10
+ import {mockRegExpsList} from '../mocking/constants.mock.ts';
11
+ import {type RunType} from '../types.ts';
12
+
13
+ // ========================================================================
14
+ // TEST Types
15
+ // Bellow test Types cant be defined inside getTestData() function, so are defined here
16
+ // ========================================================================
17
+
18
+ enum Color {
19
+ Red = 'red',
20
+ Green = 'green',
21
+ Blue = 'blue',
22
+ }
23
+
24
+ interface SmallObject {
25
+ prop1: string;
26
+ prop2: number;
27
+ prop3: boolean;
28
+ prop4?: Date;
29
+ prop5?: bigint;
30
+ }
31
+
32
+ // classes
33
+
34
+ class MySerializableClass {
35
+ name: string;
36
+ surname: string;
37
+ id: number;
38
+ startDate: Date;
39
+ constructor() {
40
+ this.name = 'John';
41
+ this.surname = 'Doe';
42
+ this.id = 0;
43
+ this.startDate = new Date('2000-08-06T02:13:00.000Z');
44
+ }
45
+ getConstructorParams(): [] {
46
+ return [];
47
+ }
48
+ getFullName() {
49
+ return `${this.name} ${this.surname}`;
50
+ }
51
+ }
52
+
53
+ class NonSerializableClass {
54
+ constructor(
55
+ public name: string,
56
+ public surname: string,
57
+ public id: number,
58
+ public startDate: Date
59
+ ) {}
60
+ getFullName() {
61
+ return `${this.name} ${this.surname}`;
62
+ }
63
+ }
64
+
65
+ // circular refs
66
+
67
+ type ObjCircularArr = {
68
+ a: string;
69
+ deep?: {
70
+ b: string;
71
+ c: number;
72
+ };
73
+ d?: ObjCircularArr[];
74
+ };
75
+
76
+ interface ICircularDeep {
77
+ name: string;
78
+ big: bigint;
79
+ embedded: {
80
+ hello: string;
81
+ child?: ICircularDeep;
82
+ };
83
+ }
84
+ interface ICircularDate {
85
+ date: Date;
86
+ month: number;
87
+ year: number;
88
+ embedded?: ICircularDate;
89
+ deep?: ICircularDeep;
90
+ }
91
+ interface RootCircular {
92
+ isRoot: true;
93
+ ciChild: ICircularDeep;
94
+ ciRoort?: RootCircular;
95
+ ciDate: ICircularDate;
96
+ }
97
+
98
+ interface RootNotCircular {
99
+ isRoot: true;
100
+ ciChild: ICircularDeep;
101
+ }
102
+
103
+ interface ICircularArray {
104
+ name: string;
105
+ children?: ICircularArray[];
106
+ }
107
+
108
+ interface ICircularTuple {
109
+ name: string;
110
+ parent?: [string, ICircularTuple];
111
+ }
112
+
113
+ interface ObjectWithMethods {
114
+ name: string;
115
+ methodProp: () => any;
116
+ }
117
+
118
+ // ========================================================================
119
+ // SERIALIZATION_TEST_DATA - Reusable test data for all serializers/deserializers
120
+ // ========================================================================
121
+
122
+ export type SingleTest = {
123
+ title: string;
124
+ description?: string; // extended functionality description
125
+ getTestData: (dataOnly?: boolean) => {
126
+ /** RunType to be used for serialization */
127
+ rt: RunType;
128
+ /** Values to be serialized */
129
+ values: any[];
130
+ /**
131
+ * Deserialized values,
132
+ * Set only when the expected deserialized values are different from the original values
133
+ * So serialization/deserialization is asymmetric
134
+ * */
135
+ deserializedValues?: any[];
136
+ };
137
+ };
138
+ export type CategoryTest = Record<string, SingleTest>;
139
+ export type TestSuite = Record<string, CategoryTest>;
140
+
141
+ export const SERIALIZATION_SPEC = {
142
+ ATOMIC: {
143
+ string: {
144
+ title: 'string',
145
+ getTestData: (dataOnly = false) => {
146
+ const rt = dataOnly ? (null as any) : runType<string>();
147
+ const values = ['hello', '', 'world', '', '你好', 'مرحبا', 'Здравствуйте', '🌍🚀✨'];
148
+ return {rt, values};
149
+ },
150
+ },
151
+ number: {
152
+ title: 'number',
153
+ getTestData: (dataOnly = false) => {
154
+ const rt = dataOnly ? (null as any) : runType<number>();
155
+ const values = [
156
+ 0,
157
+ 99,
158
+ -1,
159
+ 1.1,
160
+ -1.1,
161
+ 1988,
162
+ 2045,
163
+ 2 ** 31,
164
+ Number.MAX_SAFE_INTEGER,
165
+ Number.MIN_SAFE_INTEGER,
166
+ Number.MIN_VALUE,
167
+ Number.MAX_VALUE,
168
+ ];
169
+ return {rt, values};
170
+ },
171
+ },
172
+ number_not_supported: {
173
+ title: 'number values not supported by all protocols',
174
+ getTestData: (dataOnly = false) => {
175
+ const rt = dataOnly ? (null as any) : runType<number>();
176
+ const values = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NaN];
177
+ return {rt, values};
178
+ },
179
+ },
180
+ regexp: {
181
+ title: 'regexp',
182
+ getTestData: (dataOnly = false) => {
183
+ const rt = dataOnly ? (null as any) : runType<RegExp>();
184
+ const values = mockRegExpsList;
185
+ return {rt, values};
186
+ },
187
+ },
188
+ bigint: {
189
+ title: 'bigint',
190
+ getTestData: (dataOnly = false) => {
191
+ const rt = dataOnly ? (null as any) : runType<bigint>();
192
+ const values = [1n];
193
+ return {rt, values};
194
+ },
195
+ },
196
+ boolean: {
197
+ title: 'boolean',
198
+ getTestData: (dataOnly = false) => {
199
+ const rt = dataOnly ? (null as any) : runType<boolean>();
200
+ const values = [true];
201
+ return {rt, values};
202
+ },
203
+ },
204
+ // TODO, any is not supported by non native protocols like binary because JIT code is generated for each type unlike JSON.stringify(any)
205
+ // so we might change this or use a flag to throw if any types is used
206
+ any: {
207
+ title: 'any',
208
+ getTestData: (dataOnly = false) => {
209
+ const rt = dataOnly ? (null as any) : runType<any>();
210
+ const values = [42, 'hello', true, null, 0, -1, 1.1, {a: 1, b: 2}, [1, 2, 3, null]];
211
+ return {rt, values};
212
+ },
213
+ },
214
+ not_supported_any: {
215
+ title: 'not supported in JSON stringify when any type is used',
216
+ getTestData: (dataOnly = false) => {
217
+ const rt = dataOnly ? (null as any) : runType<any>();
218
+ // some values are not supported when any type is used
219
+ const values = [undefined, [undefined, 123, null], new Date('2000-08-06T02:13:00.000Z'), BigInt(1)];
220
+ return {rt, values};
221
+ },
222
+ },
223
+ null: {
224
+ title: 'null',
225
+ getTestData: (dataOnly = false) => {
226
+ const rt = dataOnly ? (null as any) : runType<null>();
227
+ const values = [null];
228
+ return {rt, values};
229
+ },
230
+ },
231
+ undefined: {
232
+ title: 'undefined',
233
+ getTestData: (dataOnly = false) => {
234
+ const rt = dataOnly ? (null as any) : runType<undefined>();
235
+ const values = [undefined];
236
+ return {rt, values};
237
+ },
238
+ },
239
+ date: {
240
+ title: 'date',
241
+ getTestData: (dataOnly = false) => {
242
+ const rt = dataOnly ? (null as any) : runType<Date>();
243
+ const values = [new Date('2000-08-06T02:13:00.000Z')];
244
+ return {rt, values};
245
+ },
246
+ },
247
+ enum: {
248
+ title: 'enum',
249
+ getTestData: (dataOnly = false) => {
250
+ const rt = dataOnly ? (null as any) : runType<Color>();
251
+ const values = [Color.Red, Color.Green];
252
+ return {rt, values};
253
+ },
254
+ },
255
+ symbol: {
256
+ title: 'symbol',
257
+ getTestData: (dataOnly = false) => {
258
+ const rt = dataOnly ? (null as any) : runType<symbol>();
259
+ const values = [Symbol('foo'), Symbol()];
260
+ return {rt, values};
261
+ },
262
+ },
263
+ object: {
264
+ title: 'object',
265
+ getTestData: (dataOnly = false) => {
266
+ const rt = dataOnly ? (null as any) : runType<object>();
267
+ const values = [{a: 42, b: 'hello'}, null];
268
+ return {rt, values};
269
+ },
270
+ },
271
+ void: {
272
+ title: 'void',
273
+ getTestData: (dataOnly = false) => {
274
+ const rt = dataOnly ? (null as any) : runType<void>();
275
+ const values = [undefined];
276
+ return {rt, values};
277
+ },
278
+ },
279
+ never: {
280
+ title: 'never',
281
+ getTestData: (dataOnly = false) => {
282
+ const rt = dataOnly ? (null as any) : runType<never>();
283
+ const values = []; // never is not serializable, should throw
284
+ return {rt, values};
285
+ },
286
+ },
287
+ literal_string: {
288
+ title: 'string literal',
289
+ getTestData: (dataOnly = false) => {
290
+ const rt = dataOnly ? (null as any) : runType<'hello'>();
291
+ const values = ['hello'];
292
+ return {rt, values};
293
+ },
294
+ },
295
+ literal_number: {
296
+ title: 'number literal',
297
+ getTestData: (dataOnly = false) => {
298
+ const rt = dataOnly ? (null as any) : runType<42>();
299
+ const values = [42];
300
+ return {rt, values};
301
+ },
302
+ },
303
+ literal_boolean: {
304
+ title: 'boolean literal',
305
+ getTestData: (dataOnly = false) => {
306
+ const rt = dataOnly ? (null as any) : runType<true>();
307
+ const values = [true];
308
+ return {rt, values};
309
+ },
310
+ },
311
+ literal_regexp: {
312
+ title: 'regexp literal',
313
+ getTestData: (dataOnly = false) => {
314
+ const reg = /abc/;
315
+ const rt = dataOnly ? (null as any) : runType<typeof reg>();
316
+ const values = [reg];
317
+ return {rt, values};
318
+ },
319
+ },
320
+ },
321
+ ARRAYS: {
322
+ array: {
323
+ title: 'array',
324
+ getTestData: (dataOnly = false) => {
325
+ const rt = dataOnly ? (null as any) : runType<string[]>();
326
+ const values = [['hello', 'world'], []];
327
+ return {rt, values};
328
+ },
329
+ },
330
+ array_date: {
331
+ title: 'array of dates',
332
+ getTestData: (dataOnly = false) => {
333
+ const rt = dataOnly ? (null as any) : runType<Date[]>();
334
+ const values = [[new Date('2000-08-06T02:13:00.000Z'), new Date('2001-09-07T03:14:00.000Z')], []];
335
+ return {rt, values};
336
+ },
337
+ },
338
+ undefined_in_array: {
339
+ title: 'undefined is serialized as null in array',
340
+ getTestData: (dataOnly = false) => {
341
+ const rt = dataOnly ? (null as any) : runType<undefined[]>();
342
+ const original: undefined[] = [undefined, undefined];
343
+ const values = [original];
344
+ return {rt, values};
345
+ },
346
+ },
347
+ multi_dimensional: {
348
+ title: 'multi dimensional array',
349
+ getTestData: (dataOnly = false) => {
350
+ const rt = dataOnly ? (null as any) : runType<string[][]>();
351
+ const values = [[['hello', 'world'], ['a', 'b'], []], []];
352
+ return {rt, values};
353
+ },
354
+ },
355
+ non_serializable_in_array: {
356
+ title: 'non serializable items throws an error',
357
+ description: 'non serializable in array throws an error at compile time. ',
358
+ getTestData: (dataOnly = false) => {
359
+ type NonSerializableArray = symbol[];
360
+ const rt = dataOnly ? (null as any) : runType<NonSerializableArray>();
361
+ const values = []; // doesn't matter as should throw at compile time
362
+ return {rt, values};
363
+ },
364
+ },
365
+ circular: {
366
+ title: 'array circular',
367
+ getTestData: (dataOnly = false) => {
368
+ type CircularArray = CircularArray[]; // this type is not really useful as only allows empty array, but still posible
369
+ const rt = dataOnly ? (null as any) : runType<CircularArray>();
370
+ const arr: CircularArray = [];
371
+ arr.push([]);
372
+ arr[0].push([]);
373
+ arr[0][0].push([]);
374
+ const values = [arr, []];
375
+ return {rt, values};
376
+ },
377
+ },
378
+ },
379
+ OBJECTS: {
380
+ interface: {
381
+ title: 'interface',
382
+ getTestData: (dataOnly = false) => {
383
+ type TestInterface = {
384
+ startDate: Date;
385
+ quantity: number;
386
+ name: string;
387
+ nullValue: null;
388
+ big: bigint;
389
+ stringArray: string[];
390
+ "weird prop name \n?>'\\\t\r": string;
391
+ optionalString?: string;
392
+ };
393
+ const rt = dataOnly ? (null as any) : runType<TestInterface>();
394
+ const value: TestInterface = {
395
+ startDate: new Date('2000-08-06T02:13:00.000Z'),
396
+ quantity: 123,
397
+ name: 'hello',
398
+ nullValue: null,
399
+ big: BigInt(123),
400
+ stringArray: ['a', 'b', 'c'],
401
+ "weird prop name \n?>'\\\t\r": 'hello2',
402
+ };
403
+ const valueWIthOptional: TestInterface = {
404
+ ...value,
405
+ optionalString: 'hello3',
406
+ };
407
+ const values = [value, valueWIthOptional];
408
+ return {rt, values};
409
+ },
410
+ },
411
+ many_optional_props: {
412
+ title: 'interface',
413
+ getTestData: (dataOnly = false) => {
414
+ type N = number;
415
+ // prettier-ignore
416
+ type ManyOptional = {
417
+ // 8 bitmap
418
+ a0?: N; a1?: N; a2?: N; a3?: N; a4?: N; a5?: N; a6?: N; a7?:N;
419
+ a8?: N; a9?: N; a10?: N; a11?: N; a12?: N; a13?: N; a14?: N; a15?: N;
420
+ b0?: N; b1?: N; b2?: N; b3?: N; b4?: N; b5?: N; b6?: N; b7?: N;
421
+ b8?: N; b9?: N; b10?: N; b11?: N; b12?: N; b13?: N; b14?: N; b15?: N;
422
+ };
423
+ const rt = dataOnly ? (null as any) : runType<ManyOptional>();
424
+ // prettier-ignore
425
+ const value1: ManyOptional = {a0: 0, a1: 1, b0:16, a8: 8, b7: 23, b15: 31};
426
+ // prettier-ignore
427
+ const values2: ManyOptional = {a0: 0, b8: 24};
428
+ const values3: ManyOptional = {};
429
+ const values = [value1, values2, values3];
430
+ return {rt, values};
431
+ },
432
+ },
433
+ class: {
434
+ title: 'class',
435
+ getTestData: (dataOnly = false) => {
436
+ const rt = dataOnly ? (null as any) : runType<MySerializableClass>();
437
+ // class deserialization are asymmetric, restored values only contains the properties
438
+ // class are deserialized as a plain objects instead original class instance
439
+ const item = new MySerializableClass();
440
+ const restored = {
441
+ name: item.name,
442
+ surname: item.surname,
443
+ id: item.id,
444
+ startDate: item.startDate,
445
+ };
446
+ const values = [new MySerializableClass()];
447
+ const deserializedValues = [restored];
448
+ return {rt, values, deserializedValues};
449
+ },
450
+ },
451
+ extended_class: {
452
+ title: 'extended class',
453
+ getTestData: (dataOnly = false) => {
454
+ class BaseClass {
455
+ baseProp: string = 'base';
456
+ }
457
+ class ExtendedClass extends BaseClass {
458
+ extendedProp: string = 'extended';
459
+ }
460
+ const rt = dataOnly ? (null as any) : runType<ExtendedClass>();
461
+ const values = [new ExtendedClass()];
462
+ return {rt, values};
463
+ },
464
+ },
465
+ rpc_error_class: {
466
+ title: 'rpc error class',
467
+ getTestData: (dataOnly = false) => {
468
+ const rt = dataOnly ? (null as any) : runType<RpcError<'test-error'>>();
469
+ const error = new RpcError({
470
+ publicMessage: 'error',
471
+ message: 'error',
472
+ type: 'test-error',
473
+ });
474
+ const values = [error];
475
+ return {rt, values};
476
+ },
477
+ },
478
+ serializable_class_restored: {
479
+ title: 'serializable class can be restored after they are registered',
480
+ getTestData: (dataOnly = false) => {
481
+ const rt = dataOnly ? (null as any) : runType<MySerializableClass>();
482
+ const values = [new MySerializableClass()];
483
+ // Register class so it can be deserialized, this would ensure we have a reference to the class
484
+ getJitUtils().setSerializableClass(MySerializableClass);
485
+ return {rt, values};
486
+ },
487
+ },
488
+ classes_deserialize_function: {
489
+ title: 'classes can be deserialized using a deserialize function',
490
+ getTestData: (dataOnly = false) => {
491
+ const rt = dataOnly ? (null as any) : runType<NonSerializableClass>();
492
+ const values = [new NonSerializableClass('John', 'Doe', 0, new Date('2000-08-06T02:13:00.000Z'))];
493
+ if (!getJitUtils().getDeserializeFn(NonSerializableClass.name)) {
494
+ getJitUtils().setDeserializeFn(NonSerializableClass, (deserialized: DataOnly<NonSerializableClass>) => {
495
+ return new NonSerializableClass(
496
+ deserialized.name,
497
+ deserialized.surname,
498
+ deserialized.id,
499
+ deserialized.startDate
500
+ );
501
+ });
502
+ }
503
+ return {rt, values};
504
+ },
505
+ },
506
+ undefined_in_object: {
507
+ title: 'undefined is omitted in object prop',
508
+ getTestData: (dataOnly = false) => {
509
+ const rt = dataOnly ? (null as any) : runType<{a: string; b: number; c: undefined}>();
510
+ const values = [{a: 'hello', b: 42, c: undefined}];
511
+ const deserializedValues = [{a: 'hello', b: 42}];
512
+ return {rt, values, deserializedValues};
513
+ },
514
+ },
515
+ optional_properties_order: {
516
+ title: 'optional properties',
517
+ getTestData: (dataOnly = false) => {
518
+ type Obj1 = {
519
+ a: string;
520
+ b?: string;
521
+ };
522
+ const rt = dataOnly ? (null as any) : runType<Obj1>();
523
+ const values = [{a: 'helloA', b: 'helloB'}, {a: 'helloA'}];
524
+ return {rt, values};
525
+ },
526
+ },
527
+ all_optional_fields: {
528
+ title: 'should work when all fields are optional',
529
+ getTestData: (dataOnly = false) => {
530
+ type Obj2 = {
531
+ a?: string;
532
+ b?: string;
533
+ };
534
+ const rt = dataOnly ? (null as any) : runType<Obj2>();
535
+ const values = [{a: 'helloA', b: 'helloB'}, {a: 'helloA'}, {}];
536
+ return {rt, values};
537
+ },
538
+ },
539
+ strip_extra_params: {
540
+ title: 'strip extra params',
541
+ getTestData: (dataOnly = false) => {
542
+ type SomeObject = {
543
+ startDate: Date;
544
+ quantity: number;
545
+ name: string;
546
+ nullValue: null;
547
+ stringArray: string[];
548
+ bigInt: bigint;
549
+ optionalString?: string;
550
+ "weird prop name \n?>'\\\t\r": string;
551
+ deep: {
552
+ a: string;
553
+ b: number;
554
+ };
555
+ '?other weird p': {
556
+ c: string;
557
+ d: number;
558
+ };
559
+ };
560
+ const rt = dataOnly ? (null as any) : runType<SomeObject>();
561
+ const startDate = new Date('2000-08-06T02:13:00.000Z');
562
+ const noExtraParams: SomeObject = {
563
+ startDate,
564
+ quantity: 123,
565
+ name: 'hello',
566
+ nullValue: null,
567
+ stringArray: ['a', 'b', 'c'],
568
+ bigInt: BigInt(123),
569
+ "weird prop name \n?>'\\\t\r": 'hello2',
570
+ deep: {a: 'hello', b: 123},
571
+ '?other weird p': {c: 'hello', d: 123},
572
+ };
573
+ const objectWithExtraParams = {
574
+ ...noExtraParams,
575
+ startDate: new Date('2000-08-06T02:13:00.000Z'),
576
+ deep: {a: 'hello', b: 123, cExtra: true},
577
+ '?other weird p': {c: 'hello', d: 123, eExtra: true},
578
+ extraA: 'hello',
579
+ extraB: 123,
580
+ extraC: true,
581
+ };
582
+ const values = [objectWithExtraParams];
583
+ const deserializedValues = [noExtraParams];
584
+ return {rt, values, deserializedValues};
585
+ },
586
+ },
587
+ interface_circular: {
588
+ title: 'interface circular',
589
+ getTestData: (dataOnly = false) => {
590
+ interface ICircular {
591
+ name: string;
592
+ child?: ICircular;
593
+ }
594
+ const rt = dataOnly ? (null as any) : runType<ICircular>();
595
+ const values = [{name: 'hello', child: {name: 'world'}}];
596
+ return {rt, values};
597
+ },
598
+ },
599
+ interface_circular_array: {
600
+ title: 'interface circular array',
601
+ getTestData: (dataOnly = false) => {
602
+ const rt = dataOnly ? (null as any) : runType<ICircularArray>();
603
+ const values: ICircularArray[] = [
604
+ {name: 'hello', children: []},
605
+ {name: 'hello', children: [{name: 'world'}]},
606
+ ];
607
+ return {rt, values};
608
+ },
609
+ },
610
+ interface_circular_deep: {
611
+ title: 'interface circular deep',
612
+ getTestData: (dataOnly = false) => {
613
+ const rt = dataOnly ? (null as any) : runType<ICircularDeep>();
614
+ const values: ICircularDeep[] = [
615
+ {name: 'hello', big: 1n, embedded: {hello: 'world'}},
616
+ {
617
+ name: 'hello',
618
+ big: 2n,
619
+ embedded: {hello: 'world', child: {name: 'world1', big: 3n, embedded: {hello: 'world2'}}},
620
+ },
621
+ ];
622
+ return {rt, values};
623
+ },
624
+ },
625
+ interface_root_not_circular: {
626
+ title: 'interface root not circular',
627
+ getTestData: (dataOnly = false) => {
628
+ const rt = dataOnly ? (null as any) : runType<RootNotCircular>();
629
+ const values: RootNotCircular[] = [
630
+ {
631
+ isRoot: true,
632
+ ciChild: {name: 'hello', big: 1n, embedded: {hello: 'world'}},
633
+ },
634
+ {
635
+ isRoot: true,
636
+ ciChild: {
637
+ name: 'hello',
638
+ big: 2n,
639
+ embedded: {
640
+ hello: 'world',
641
+ child: {name: 'world1', big: 2n, embedded: {hello: 'world2'}},
642
+ },
643
+ },
644
+ },
645
+ ];
646
+ return {rt, values};
647
+ },
648
+ },
649
+ interface_multiple_circular: {
650
+ title: 'interface multiple circular',
651
+ getTestData: (dataOnly = false) => {
652
+ const rt = dataOnly ? (null as any) : runType<RootCircular>();
653
+ const ciDate: ICircularDate = {date: new Date('2000-08-06T02:13:00.000Z'), month: 1, year: 2021};
654
+ const values = [
655
+ {isRoot: true, ciChild: {name: 'hello', big: 1n, embedded: {hello: 'world'}}, ciDate},
656
+ {
657
+ isRoot: true,
658
+ ciChild: {
659
+ name: 'hello',
660
+ big: 1n,
661
+ embedded: {hello: 'world', child: {name: 'world1', big: 1n, embedded: {hello: 'world2'}}},
662
+ },
663
+ ciDate,
664
+ },
665
+ ];
666
+ return {rt, values};
667
+ },
668
+ },
669
+ interface_with_methods: {
670
+ title: 'methods should be excluded from interface when serializing',
671
+ getTestData: (dataOnly = false) => {
672
+ const rt = dataOnly ? (null as any) : runType<ObjectWithMethods>();
673
+ const objWithMethod = {
674
+ name: 'John',
675
+ methodProp() {
676
+ return 'method result';
677
+ },
678
+ } as ObjectWithMethods;
679
+ const values = [objWithMethod];
680
+ const deserializedValues = [{name: 'John'}]; // method should be excluded
681
+ return {rt, values, deserializedValues};
682
+ },
683
+ },
684
+ },
685
+ // Records are Object/Interfaces that use index properties where prop names are unknown at compile time
686
+ RECORDS: {
687
+ index_property: {
688
+ title: 'index property',
689
+ getTestData: (dataOnly = false) => {
690
+ interface IndexString {
691
+ [key: string]: string;
692
+ }
693
+ const rt = dataOnly ? (null as any) : runType<IndexString>();
694
+ const values = [{key1: 'value1', key2: 'value2'}, {}];
695
+ return {rt, values};
696
+ },
697
+ },
698
+ index_property_and_prop: {
699
+ title: 'interfaces with a single property and index properties',
700
+ getTestData: (dataOnly = false) => {
701
+ type Obj1 = {
702
+ a: string;
703
+ [key: string]: string;
704
+ };
705
+ const rt = dataOnly ? (null as any) : runType<Obj1>();
706
+ const values = [{a: 'helloA'}, {a: 'helloA', b: 'helloB'}];
707
+ return {rt, values};
708
+ },
709
+ },
710
+ index_property_extra: {
711
+ title: 'index property with extra props and unions',
712
+ getTestData: (dataOnly = false) => {
713
+ type IndexWithExtraProps = {
714
+ a: string;
715
+ b: number;
716
+ [key: string]: string | number;
717
+ };
718
+ const rt = dataOnly ? (null as any) : runType<IndexWithExtraProps>();
719
+ const value: IndexWithExtraProps = {
720
+ key1: 'value1',
721
+ key2: 'value2',
722
+ a: 'extra1',
723
+ b: 123,
724
+ };
725
+ const values = [value];
726
+ return {rt, values};
727
+ },
728
+ },
729
+ multiple_index_props: {
730
+ title: 'multiple index properties',
731
+ getTestData: (dataOnly = false) => {
732
+ type MultipleIndex = {
733
+ [key: string]: string;
734
+ [key: number]: string;
735
+ [abc: symbol]: Date;
736
+ };
737
+ const objWithSymbolKeys: MultipleIndex = {
738
+ key1: 'value1',
739
+ key2: 'value2',
740
+ [Symbol('key3')]: new Date(),
741
+ [Symbol('key4')]: new Date(),
742
+ }; // symbol keys should be skipped from jit
743
+ const rt = dataOnly ? (null as any) : runType<MultipleIndex>();
744
+ const values = [{key1: 'value1', key2: 'value2'}, objWithSymbolKeys];
745
+ const deserializedValues = [
746
+ {key1: 'value1', key2: 'value2'},
747
+ {key1: 'value1', key2: 'value2'},
748
+ ]; // symbol keys should be skipped
749
+ return {rt, values, deserializedValues};
750
+ },
751
+ },
752
+ index_property_nested: {
753
+ title: 'index property nested',
754
+ getTestData: (dataOnly = false) => {
755
+ const rt = dataOnly ? (null as any) : runType<{[key: string]: {[key: string]: number}}>();
756
+ const values = [{key1: {nestedKey1: 1, nestedKey2: 2}}];
757
+ return {rt, values};
758
+ },
759
+ },
760
+ index_property_nested_date: {
761
+ title: 'index property nested date',
762
+ getTestData: (dataOnly = false) => {
763
+ const rt = dataOnly ? (null as any) : runType<{[key: string]: {[key: string]: Date}}>();
764
+ const values = [
765
+ {key1: {nestedKey1: new Date('2000-08-06T02:13:00.000Z'), nestedKey2: new Date('2000-08-06T02:13:00.000Z')}},
766
+ ];
767
+ return {rt, values};
768
+ },
769
+ },
770
+ index_property_bigint: {
771
+ title: 'index property with bigint values',
772
+ getTestData: (dataOnly = false) => {
773
+ const rt = dataOnly ? (null as any) : runType<{[key: string]: bigint}>();
774
+ const values = [
775
+ {key1: 1n, key2: 2n},
776
+ {hello: 1n, world: 2n},
777
+ ];
778
+ return {rt, values};
779
+ },
780
+ },
781
+ index_property_non_root: {
782
+ title: 'index property non-root',
783
+ getTestData: (dataOnly = false) => {
784
+ interface Obj1 {
785
+ a: string;
786
+ [key: string]: string;
787
+ }
788
+ interface Obj2 {
789
+ b: string;
790
+ c: Obj1;
791
+ }
792
+ const rt = dataOnly ? (null as any) : runType<Obj2>();
793
+ const values = [{b: 'hello', c: {a: 'world', c: 'world'}}];
794
+ return {rt, values};
795
+ },
796
+ },
797
+ },
798
+ TUPLES: {
799
+ tuple: {
800
+ title: 'tuple',
801
+ getTestData: (dataOnly = false) => {
802
+ type TestTuple = [Date, number, string, null, string[], bigint];
803
+ const rt = dataOnly ? (null as any) : runType<TestTuple>();
804
+ const tuple: TestTuple = [new Date('2000-08-06T02:13:00.000Z'), 123, 'hello', null, ['a', 'b', 'c'], BigInt(123)];
805
+ const values = [tuple];
806
+ return {rt, values};
807
+ },
808
+ },
809
+ tuple_with_optional: {
810
+ title: 'tuple with optional params',
811
+ getTestData: (dataOnly = false) => {
812
+ type TupleWithOptionals = [number, bigint?, boolean?, number?];
813
+ const rt = dataOnly ? (null as any) : runType<TupleWithOptionals>();
814
+ // Note: Jest's toEqual was more lenient with undefined values in arrays
815
+ // Vitest is stricter, so we explicitly include undefined for optional params
816
+ const values: TupleWithOptionals[] = [
817
+ [3, undefined, true, 4],
818
+ [446, undefined, undefined, undefined],
819
+ ];
820
+ return {rt, values};
821
+ },
822
+ },
823
+ tuple_rest_parameter: {
824
+ title: 'tuple rest parameter',
825
+ getTestData: (dataOnly = false) => {
826
+ type TupleRest = [number, ...bigint[]];
827
+ const rt = dataOnly ? (null as any) : runType<TupleRest>();
828
+ const values: TupleRest[] = [[34567, 1n, 2n, 3n], [3]];
829
+ return {rt, values};
830
+ },
831
+ },
832
+ tuple_with_non_serializable: {
833
+ title: 'tuple with non serializable types are transformed to undefined',
834
+ description:
835
+ 'tuples relies in the order and length of the array to work, so non serializable types are transformed to undefined, to keep the order and length of the tuple.',
836
+ getTestData: (dataOnly = false) => {
837
+ type TupleWithNonSerializable = [number, () => any];
838
+ const rt = dataOnly ? (null as any) : runType<TupleWithNonSerializable>();
839
+ const values = [[3, () => null]];
840
+ const deserializedValues = [[3, undefined]];
841
+ return {rt, values, deserializedValues};
842
+ },
843
+ },
844
+ tuple_circular: {
845
+ title: 'tuple circular',
846
+ getTestData: (dataOnly = false) => {
847
+ type TupleCircular = [Date, number, string, null, string[], bigint, TupleCircular?];
848
+ const rt = dataOnly ? (null as any) : runType<TupleCircular>();
849
+ // Note: Jest's toEqual was more lenient with undefined values in arrays
850
+ // Vitest is stricter, so we explicitly include undefined for optional params
851
+ const tDeep: TupleCircular = [
852
+ new Date('2000-08-06T02:13:00.000Z'),
853
+ 456,
854
+ 'world',
855
+ null,
856
+ ['x', 'y', 'z'],
857
+ BigInt(456),
858
+ undefined,
859
+ ];
860
+ const typeValue: TupleCircular = [
861
+ new Date('2000-08-06T02:13:00.000Z'),
862
+ 123,
863
+ 'hello',
864
+ null,
865
+ ['a', 'b', 'c'],
866
+ BigInt(123),
867
+ tDeep,
868
+ ];
869
+ const values = [typeValue];
870
+ return {rt, values};
871
+ },
872
+ },
873
+ interface_circular_tuple: {
874
+ title: 'interface circular tuple',
875
+ getTestData: (dataOnly = false) => {
876
+ const rt = dataOnly ? (null as any) : runType<ICircularTuple>();
877
+ const obj1: ICircularTuple = {name: 'hello', parent: ['world', {name: 'world'}]};
878
+ const obj2: ICircularTuple = {name: 'hello', parent: ['world', {name: 'world', parent: ['hello', obj1]}]};
879
+ const values = [obj1, obj2];
880
+ return {rt, values};
881
+ },
882
+ },
883
+ },
884
+ FUNCTIONS: {
885
+ throw_errors_for_functions: {
886
+ title: 'throw errors for functions',
887
+ getTestData: (dataOnly = false) => {
888
+ type TestFunction = (a: number, b: boolean, c?: string) => Date;
889
+ const rt = dataOnly ? (null as any) : runType<TestFunction>();
890
+ const values = []; // This test throws an error, so no values
891
+ return {rt, values};
892
+ },
893
+ },
894
+ parameters: {
895
+ title: 'parameters',
896
+ getTestData: (dataOnly = false) => {
897
+ type TestFunction = (a: number, b: boolean, c: string) => Date;
898
+ const rt = dataOnly ? (null as any) : runType<TestFunction>();
899
+ const values = [
900
+ [3, true, 'hello'],
901
+ [3, true, 'world'],
902
+ ];
903
+ return {rt, values};
904
+ },
905
+ },
906
+ optional_params: {
907
+ title: 'optional parameters',
908
+ getTestData: (dataOnly = false) => {
909
+ type TestFunction2 = (a: Date, b?: boolean) => bigint;
910
+ const rt = dataOnly ? (null as any) : runType<TestFunction2>();
911
+ const d = new Date('2000-08-06T02:13:00.000Z');
912
+ const values = [[d, true], [d]];
913
+ return {rt, values};
914
+ },
915
+ },
916
+ function_return: {
917
+ title: 'function return',
918
+ getTestData: (dataOnly = false) => {
919
+ type TestFunction = (a: number, b: boolean, c?: string) => Date;
920
+ const rt = dataOnly ? (null as any) : runType<TestFunction>();
921
+ const values = [new Date('2000-08-06T02:13:00.000Z')];
922
+ return {rt, values};
923
+ },
924
+ },
925
+ function_with_rest_parameters: {
926
+ title: 'stringify function with rest parameters',
927
+ getTestData: (dataOnly = false) => {
928
+ type TestFunctionRest = (a: number, b: boolean, ...rest: Date[]) => Date;
929
+ const rt = dataOnly ? (null as any) : runType<TestFunctionRest>();
930
+ const values = [
931
+ [3, true, new Date('2000-08-06T02:13:00.000Z'), new Date('2000-08-06T02:13:00.000Z')],
932
+ [3, true],
933
+ ];
934
+ return {rt, values};
935
+ },
936
+ },
937
+ function_with_date_parameters: {
938
+ title: 'function with Date parameters requiring serialization',
939
+ getTestData: (dataOnly = false) => {
940
+ type TestFunctionDate = (a: Date, b?: boolean) => bigint;
941
+ const rt = dataOnly ? (null as any) : runType<TestFunctionDate>();
942
+ const d = new Date('2000-08-06T02:13:00.000Z');
943
+ const values = [[d, true], [d]];
944
+ return {rt, values};
945
+ },
946
+ },
947
+ required_function_return: {
948
+ title: 'required function return',
949
+ getTestData: (dataOnly = false) => {
950
+ type TestFunction2 = (a: Date, b?: boolean) => bigint;
951
+ const rt = dataOnly ? (null as any) : runType<TestFunction2>();
952
+ const values = [1n];
953
+ return {rt, values};
954
+ },
955
+ },
956
+ function_with_only_rest_parameters: {
957
+ title: 'stringify function with only rest parameters',
958
+ getTestData: (dataOnly = false) => {
959
+ type TestFunctionRest2 = (...rest: number[]) => Date;
960
+ const rt = dataOnly ? (null as any) : runType<TestFunctionRest2>();
961
+ const values = [[3, 2, 1], []];
962
+ return {rt, values};
963
+ },
964
+ },
965
+ non_serializable_params: {
966
+ title: 'non serializable types',
967
+ getTestData: (dataOnly = false) => {
968
+ type TestFunctionWithFN = (a: number, b: boolean, c?: () => null) => Date;
969
+ const rt = dataOnly ? (null as any) : runType<TestFunctionWithFN>();
970
+ const values = [
971
+ [3, true, () => null],
972
+ [3, true, undefined],
973
+ ];
974
+ const deserializedValues = [
975
+ [3, true, undefined],
976
+ [3, true, undefined],
977
+ ];
978
+ return {rt, values, deserializedValues};
979
+ },
980
+ },
981
+ function_promise_return_type: {
982
+ title: `functions returns a promise`,
983
+ getTestData: (dataOnly = false) => {
984
+ type TestFunctionPromise = (a: number, b: boolean, c?: string) => Promise<Date>;
985
+ const rt = dataOnly ? (null as any) : runType<TestFunctionPromise>();
986
+ const values = [new Date('2000-08-06T02:13:00.000Z')]; // This tests the return value
987
+ return {rt, values};
988
+ },
989
+ },
990
+ function_return_type_is_function: {
991
+ title: `return type of a closure`,
992
+ getTestData: (dataOnly = false) => {
993
+ type TestFunctionReturnsFunction = (a: number, b: boolean, c?: string) => () => Date;
994
+ const rt = dataOnly ? (null as any) : runType<TestFunctionReturnsFunction>();
995
+ const values = [new Date('2000-08-06T02:13:00.000Z')]; // This tests the return value
996
+ return {rt, values};
997
+ },
998
+ },
999
+ reflectFunction_params: {
1000
+ title: 'should get runType from a function using reflectFunction',
1001
+ getTestData: (dataOnly = false) => {
1002
+ function abc1(a: number, b: boolean, c?: string): string {
1003
+ return `${a}-${b}-${c}`;
1004
+ }
1005
+ const rt = dataOnly ? (null as any) : reflectFunction(abc1);
1006
+ const values = [
1007
+ [3, true, 'hello'],
1008
+ [3, true],
1009
+ ];
1010
+ return {rt, values};
1011
+ },
1012
+ },
1013
+ reflectFunction_return: {
1014
+ title: 'should get runType from a function using reflectFunction',
1015
+ getTestData: (dataOnly = false) => {
1016
+ function abc2(a: number, b: boolean, c?: string): string {
1017
+ return `${a}-${b}-${c}`;
1018
+ }
1019
+ const rt = dataOnly ? (null as any) : reflectFunction(abc2);
1020
+ const values = ['1-true-c', '1-true'];
1021
+ return {rt, values};
1022
+ },
1023
+ },
1024
+ function_slice_params: {
1025
+ title: 'create jit function with params slice',
1026
+ getTestData: (dataOnly = false) => {
1027
+ type TestFunction = (a: number, b: boolean, c?: string) => Date;
1028
+ const rt = dataOnly ? (null as any) : runType<TestFunction>();
1029
+ const values = [[true, 'hello']]; // Params with slice starting from index 1
1030
+ return {rt, values};
1031
+ },
1032
+ },
1033
+ call_signature_params: {
1034
+ title: 'call signature params',
1035
+ getTestData: (dataOnly = false) => {
1036
+ type CallSignatureType = {
1037
+ (a: number, b: boolean): string;
1038
+ };
1039
+ const rt = dataOnly ? (null as any) : runType<CallSignatureType>();
1040
+ const values = [[3, true]];
1041
+ return {rt, values};
1042
+ },
1043
+ },
1044
+ call_signature_return: {
1045
+ title: 'call signature return',
1046
+ getTestData: (dataOnly = false) => {
1047
+ type CallSignatureType = {
1048
+ (a: number, b: boolean): string;
1049
+ };
1050
+ const rt = dataOnly ? (null as any) : runType<CallSignatureType>();
1051
+ const values = ['result']; // This is the return value being tested
1052
+ return {rt, values};
1053
+ },
1054
+ },
1055
+ throw_errors_for_call_signature: {
1056
+ title: 'throw errors for call signature',
1057
+ getTestData: (dataOnly = false) => {
1058
+ type CallSignatureType = {
1059
+ (a: number, b: boolean): string;
1060
+ };
1061
+ const rt = dataOnly ? (null as any) : runType<CallSignatureType>();
1062
+ const values = [[3, 'invalid']]; // This is the return value being tested
1063
+ return {rt, values};
1064
+ },
1065
+ },
1066
+ },
1067
+ UTILITY_TYPES: {
1068
+ awaited: {
1069
+ title: 'awaited',
1070
+ getTestData: (dataOnly = false) => {
1071
+ type MyPromise = Promise<{a: string; b: number; c: Date}>; // note how record does not check the type of keys
1072
+ type MyType = Awaited<MyPromise>;
1073
+ const rt = dataOnly ? (null as any) : runType<MyType>();
1074
+ const values = [{a: 'hello', b: 1, c: new Date('2000-08-06T02:13:00.000Z')}];
1075
+ return {rt, values};
1076
+ },
1077
+ },
1078
+ exclude_atomic: {
1079
+ title: 'exclude atomic',
1080
+ getTestData: (dataOnly = false) => {
1081
+ type PersonProp = 'name' | 'age' | number;
1082
+ const rt = dataOnly ? (null as any) : runType<Exclude<PersonProp, 'age'>>();
1083
+ const values = ['name', 3, 4];
1084
+ return {rt, values};
1085
+ },
1086
+ },
1087
+ exclude_objects: {
1088
+ title: 'exclude objects',
1089
+ getTestData: (dataOnly = false) => {
1090
+ type Circle = {kind: 'circle'; radius: number};
1091
+ type Square = {kind: 'square'; x: number};
1092
+ type Triangle = {kind: 'triangle'; x: number; y: number};
1093
+ type Shape = Circle | Square | Triangle;
1094
+ type ExcludeCircle = Exclude<Shape, Circle>;
1095
+ const rt = dataOnly ? (null as any) : runType<ExcludeCircle>();
1096
+ const values: ExcludeCircle[] = [
1097
+ {kind: 'square', x: 5},
1098
+ {kind: 'triangle', x: 5, y: 10},
1099
+ ];
1100
+ return {rt, values};
1101
+ },
1102
+ },
1103
+ required_properties: {
1104
+ title: 'required properties',
1105
+ getTestData: (dataOnly = false) => {
1106
+ interface MaybePerson {
1107
+ name?: string;
1108
+ age?: number;
1109
+ createdAt?: Date;
1110
+ }
1111
+ const rt = dataOnly ? (null as any) : runType<Required<MaybePerson>>();
1112
+ const createdAt = new Date('2000-08-06T02:13:00.000Z');
1113
+ const values = [{name: 'John', age: 30, createdAt}];
1114
+ return {rt, values};
1115
+ },
1116
+ },
1117
+ extract_atomic: {
1118
+ title: 'extract atomic',
1119
+ getTestData: (dataOnly = false) => {
1120
+ type PersonProp = 'name' | 'age' | 'createdAt';
1121
+ const rt = dataOnly ? (null as any) : runType<Extract<PersonProp, 'name' | 'createdAt'>>();
1122
+ const values = ['name'];
1123
+ return {rt, values};
1124
+ },
1125
+ },
1126
+ extract_objects: {
1127
+ title: 'extract objects',
1128
+ getTestData: (dataOnly = false) => {
1129
+ type Shape =
1130
+ | {kind: 'circle'; radius: number}
1131
+ | {kind: 'square'; x: number}
1132
+ | {kind: 'triangle'; x: number; y: number};
1133
+ type ToExtract = {kind: 'square'; x: number} | {kind: 'triangle'; x: number; y: number};
1134
+ const rt = dataOnly ? (null as any) : runType<Extract<Shape, ToExtract>>();
1135
+ const values = [{kind: 'square', x: 5}];
1136
+ return {rt, values};
1137
+ },
1138
+ },
1139
+ partial_properties: {
1140
+ title: 'partial properties',
1141
+ getTestData: (dataOnly = false) => {
1142
+ interface Person {
1143
+ name: string;
1144
+ age: number;
1145
+ createdAt: Date;
1146
+ }
1147
+ const rt = dataOnly ? (null as any) : runType<Partial<Person>>();
1148
+ const createdAt = new Date('2000-08-06T02:13:00.000Z');
1149
+ const values = [{name: 'John'}, {age: 30}, {createdAt}, {}];
1150
+ return {rt, values};
1151
+ },
1152
+ },
1153
+ pick_properties: {
1154
+ title: 'pick properties',
1155
+ getTestData: (dataOnly = false) => {
1156
+ interface Person {
1157
+ name: string;
1158
+ age: number;
1159
+ createdAt: Date;
1160
+ email: string;
1161
+ }
1162
+ const rt = dataOnly ? (null as any) : runType<Pick<Person, 'name' | 'createdAt'>>();
1163
+ const createdAt = new Date('2000-08-06T02:13:00.000Z');
1164
+ const values = [{name: 'John', createdAt}];
1165
+ return {rt, values};
1166
+ },
1167
+ },
1168
+ omit_properties: {
1169
+ title: 'omit properties',
1170
+ getTestData: (dataOnly = false) => {
1171
+ interface Person {
1172
+ name: string;
1173
+ age: number;
1174
+ createdAt: Date;
1175
+ email: string;
1176
+ }
1177
+ const rt = dataOnly ? (null as any) : runType<Omit<Person, 'email'>>();
1178
+ const createdAt = new Date('2000-08-06T02:13:00.000Z');
1179
+ const values = [{name: 'John', age: 30, createdAt}];
1180
+ return {rt, values};
1181
+ },
1182
+ },
1183
+ record_type: {
1184
+ title: 'record type',
1185
+ getTestData: (dataOnly = false) => {
1186
+ const rt = dataOnly ? (null as any) : runType<Record<string, Date>>();
1187
+ const date1 = new Date('2000-08-06T02:13:00.000Z');
1188
+ const date2 = new Date('2001-09-07T03:14:00.000Z');
1189
+ const values = [{key1: date1, key2: date2}, {}];
1190
+ return {rt, values};
1191
+ },
1192
+ },
1193
+ },
1194
+ UNIONS: {
1195
+ union: {
1196
+ title: 'union',
1197
+ getTestData: (dataOnly = false) => {
1198
+ type AtomicUnion = Date | number | string | null | bigint;
1199
+ const rt = dataOnly ? (null as any) : runType<AtomicUnion>();
1200
+ const values = [new Date('2000-08-06T02:13:00.000Z'), 123, 'hello', null, 3n];
1201
+ return {rt, values};
1202
+ },
1203
+ },
1204
+ union_errors: {
1205
+ title: 'union throw errors when item does not belong to the union',
1206
+ getTestData: (dataOnly = false) => {
1207
+ type AtomicUnion2 = Date | number | {isValid: boolean};
1208
+ const rt = dataOnly ? (null as any) : runType<AtomicUnion2>();
1209
+ const values = ['hello', null, true, {hello: 'world'}];
1210
+ return {rt, values};
1211
+ },
1212
+ },
1213
+ union_array: {
1214
+ title: 'union array',
1215
+ getTestData: (dataOnly = false) => {
1216
+ type UnionArr = string[] | number[] | boolean[] | Date[];
1217
+ const rt = dataOnly ? (null as any) : runType<UnionArr>();
1218
+ const values = [
1219
+ ['a', 'b', 'c'],
1220
+ [1, 2, 3],
1221
+ [true, false, true],
1222
+ [new Date('2000-08-06T02:13:00.000Z'), new Date('2001-09-07T03:14:00.000Z')],
1223
+ [],
1224
+ ];
1225
+ return {rt, values};
1226
+ },
1227
+ },
1228
+ with_discriminator: {
1229
+ title: 'with discriminator',
1230
+ getTestData: (dataOnly = false) => {
1231
+ type ArrUnion = (string | bigint | boolean | Date)[];
1232
+ const rt = dataOnly ? (null as any) : runType<ArrUnion>();
1233
+ const date = new Date('2000-08-06T02:13:00.000Z');
1234
+ const values = [
1235
+ ['a', 'b', 'c'],
1236
+ [1n, 2n, 3n],
1237
+ [true, false, true],
1238
+ [1n, 'b', date],
1239
+ ];
1240
+ return {rt, values};
1241
+ },
1242
+ },
1243
+ union_object_with_discriminator: {
1244
+ title: 'union object with discriminator',
1245
+ getTestData: (dataOnly = false) => {
1246
+ type UnionObj = {a: string; aa: boolean} | {b: number} | {c: bigint} | {d?: string};
1247
+ const rt = dataOnly ? (null as any) : runType<UnionObj>();
1248
+ const values = [{a: 'world', aa: true}, {c: 1n}, {d: 'hello'}, {}];
1249
+ return {rt, values};
1250
+ },
1251
+ },
1252
+ union_with_discriminator_property: {
1253
+ title: 'union with discriminator property',
1254
+ getTestData: (dataOnly = false) => {
1255
+ type UnionDisc =
1256
+ | {type: 'a'; otherProp: boolean}
1257
+ | {type: 'b'; otherProp: number}
1258
+ | {type: 'c'; otherProp: string; time: Date}
1259
+ | {type: boolean; otherProp: string};
1260
+ const rt = dataOnly ? (null as any) : runType<UnionDisc>();
1261
+ const values = [
1262
+ {type: 'a', otherProp: true},
1263
+ {type: 'b', otherProp: 123},
1264
+ {type: 'c', otherProp: 'hello', time: new Date('2000-08-06T02:13:00.000Z')},
1265
+ {type: true, otherProp: 'typeD'},
1266
+ ];
1267
+ return {rt, values};
1268
+ },
1269
+ },
1270
+ union_mixed_with_discriminator: {
1271
+ title: 'union mixed with discriminator',
1272
+ getTestData: (dataOnly = false) => {
1273
+ type UnionMix =
1274
+ | string[]
1275
+ | number[]
1276
+ | boolean[]
1277
+ | {a: string; aa: boolean}
1278
+ | {b: number}
1279
+ | {c: bigint; aa: 'string'};
1280
+ const rt = dataOnly ? (null as any) : runType<UnionMix>();
1281
+ const values = [['a', 'b', 'c'], {a: 'hello', aa: true}];
1282
+ return {rt, values};
1283
+ },
1284
+ },
1285
+ union_index_property_with_discriminator: {
1286
+ title: 'union index property with discriminator',
1287
+ getTestData: (dataOnly = false) => {
1288
+ type UnionIndex =
1289
+ | string[]
1290
+ | {a: string; aa: boolean}
1291
+ | {b: number}
1292
+ | {a: string; [key: string]: string}
1293
+ | {[key: string]: bigint; b: bigint};
1294
+ const rt = dataOnly ? (null as any) : runType<UnionIndex>();
1295
+ const values = [['a', 'b', 'c'], {a: 'hello', aa: true}, {b: 1n, c: 2n}];
1296
+ return {rt, values};
1297
+ },
1298
+ },
1299
+ circular_union_with_discriminator: {
1300
+ title: 'Circular Union with discriminator',
1301
+ getTestData: (dataOnly = false) => {
1302
+ type UnionC = Date | number | string | {a?: UnionC; b?: string} | UnionC[];
1303
+ const rt = dataOnly ? (null as any) : runType<UnionC>();
1304
+ const date = new Date('2000-08-06T02:13:00.000Z');
1305
+ const values = [
1306
+ new Date(date.getTime()),
1307
+ 123,
1308
+ 'hello',
1309
+ {a: {a: {}}},
1310
+ {},
1311
+ [],
1312
+ [[]],
1313
+ [123, 3, {b: 'hello'}],
1314
+ [123, 3, 'hello'],
1315
+ [[123], 3, [3, 'hello']],
1316
+ ];
1317
+ return {rt, values};
1318
+ },
1319
+ },
1320
+ union_with_methods: {
1321
+ title: 'union with methods - methods should be excluded',
1322
+ getTestData: (dataOnly = false) => {
1323
+ type UnionWithMethods =
1324
+ | {name: string; getName(): string}
1325
+ | {age: number; getAge(): number}
1326
+ | {active: boolean; isActive(): boolean};
1327
+ const rt = dataOnly ? (null as any) : runType<UnionWithMethods>();
1328
+ const objWithName = {
1329
+ name: 'John',
1330
+ getName() {
1331
+ return 'John';
1332
+ },
1333
+ } as {name: string; getName(): string};
1334
+ const objWithAge = {
1335
+ age: 25,
1336
+ getAge() {
1337
+ return 25;
1338
+ },
1339
+ } as {age: number; getAge(): number};
1340
+ const objWithActive = {
1341
+ active: true,
1342
+ isActive() {
1343
+ return true;
1344
+ },
1345
+ } as {active: boolean; isActive(): boolean};
1346
+ const values = [objWithName, objWithAge, objWithActive];
1347
+ const deserializedValues = [{name: 'John'}, {age: 25}, {active: true}];
1348
+ return {rt, values, deserializedValues};
1349
+ },
1350
+ },
1351
+ union_with_any: {
1352
+ title: 'union with any type - any is checked last as fallback',
1353
+ description:
1354
+ 'any/unknown types in unions are sorted to be checked last, so specific types are matched first before falling back to any',
1355
+ getTestData: (dataOnly = false) => {
1356
+ type UnionWithAny = number | {name: string} | any;
1357
+ const rt = dataOnly ? (null as any) : runType<UnionWithAny>();
1358
+ const values = [42, {name: 'test'}, 'fallback to any', true, null];
1359
+ return {rt, values};
1360
+ },
1361
+ },
1362
+ union_whit_non_serializable: {
1363
+ title: 'union with non serializable types throws an error',
1364
+ description:
1365
+ "should throw an error at compile time because we don't have the isType logic for non serializable, and isType is used at runtime to determine the type of the union.",
1366
+ getTestData: (dataOnly = false) => {
1367
+ type UnionWithNonSerializable = Date | number | string | (() => any);
1368
+ const rt = dataOnly ? (null as any) : runType<UnionWithNonSerializable>();
1369
+ const values = []; // doesn't matter as should throw at compile time
1370
+ return {rt, values};
1371
+ },
1372
+ },
1373
+ },
1374
+ ITERABLES: {
1375
+ set: {
1376
+ title: 'Set',
1377
+ getTestData: (dataOnly = false) => {
1378
+ const rt = dataOnly ? (null as any) : runType<Set<string>>();
1379
+ const values = [new Set<string>(['one', 'two', 'three'])];
1380
+ return {rt, values};
1381
+ },
1382
+ },
1383
+ set_small_object: {
1384
+ title: 'Set<SmallObject>',
1385
+ getTestData: (dataOnly = false) => {
1386
+ const rt = dataOnly ? (null as any) : runType<Set<SmallObject>>();
1387
+ const values = [
1388
+ new Set<SmallObject>([
1389
+ {prop1: 'value1', prop2: 1, prop3: true},
1390
+ {prop1: 'value2', prop2: 2, prop3: false, prop4: new Date('2000-08-06T02:13:00.000Z')},
1391
+ {prop1: 'value3', prop2: 3, prop3: true, prop5: BigInt(100)},
1392
+ ]),
1393
+ ];
1394
+ return {rt, values};
1395
+ },
1396
+ },
1397
+ objects_with_nested_sets: {
1398
+ title: 'objects with nested sets',
1399
+ getTestData: (dataOnly = false) => {
1400
+ type Set1 = Set<{s: string; arr: number[]}>;
1401
+ interface DeepWithSet {
1402
+ a: string;
1403
+ b: Set1;
1404
+ c: Set1;
1405
+ }
1406
+ const rt = dataOnly ? (null as any) : runType<DeepWithSet>();
1407
+ const setB: DeepWithSet['b'] = new Set([
1408
+ {s: 'a', arr: [1, 2, 3]},
1409
+ {s: 'b', arr: [4, 5, 6]},
1410
+ ]);
1411
+ const setC: DeepWithSet['c'] = new Set([
1412
+ {s: 'a', arr: [1, 2, 3]},
1413
+ {s: 'b', arr: [4, 5, 6]},
1414
+ ]);
1415
+ const values = [{a: 'a', b: setB, c: setC}];
1416
+ return {rt, values};
1417
+ },
1418
+ },
1419
+ map: {
1420
+ title: 'Map',
1421
+ getTestData: (dataOnly = false) => {
1422
+ const rt = dataOnly ? (null as any) : runType<Map<string, number>>();
1423
+ const values = [
1424
+ new Map<string, number>([
1425
+ ['one', 1],
1426
+ ['two', 2],
1427
+ ['three', 3],
1428
+ ]),
1429
+ ];
1430
+ return {rt, values};
1431
+ },
1432
+ },
1433
+ map_string_small_object: {
1434
+ title: 'Map<string, SmallObject>',
1435
+ getTestData: (dataOnly = false) => {
1436
+ const rt = dataOnly ? (null as any) : runType<Map<string, SmallObject>>();
1437
+ const values = [
1438
+ new Map<string, SmallObject>([
1439
+ ['key1', {prop1: 'value1', prop2: 1, prop3: true}],
1440
+ ['key2', {prop1: 'value2', prop2: 2, prop3: false, prop4: new Date('2000-08-06T02:13:00.000Z')}],
1441
+ ['key3', {prop1: 'value3', prop2: 3, prop3: true, prop5: BigInt(100)}],
1442
+ ]),
1443
+ ];
1444
+ return {rt, values};
1445
+ },
1446
+ },
1447
+ map_small_object_number: {
1448
+ title: 'Map<SmallObject, number>',
1449
+ getTestData: (dataOnly = false) => {
1450
+ const rt = dataOnly ? (null as any) : runType<Map<SmallObject, number>>();
1451
+ const values = [
1452
+ new Map<SmallObject, number>([
1453
+ [{prop1: 'value1', prop2: 1, prop3: true}, 1],
1454
+ [{prop1: 'value2', prop2: 2, prop3: false, prop4: new Date('2000-08-06T02:13:00.000Z')}, 2],
1455
+ [{prop1: 'value3', prop2: 3, prop3: true, prop5: BigInt(100)}, 3],
1456
+ ]),
1457
+ ];
1458
+ return {rt, values};
1459
+ },
1460
+ },
1461
+ objects_with_nested_maps: {
1462
+ title: 'objects with nested maps',
1463
+ getTestData: (dataOnly = false) => {
1464
+ interface DeepWithMap {
1465
+ a: string;
1466
+ b: Map<string, {sm: {s: string; arr: number[]}}>;
1467
+ }
1468
+ const rt = dataOnly ? (null as any) : runType<DeepWithMap>();
1469
+ const values = [
1470
+ {
1471
+ a: 'a',
1472
+ b: new Map([
1473
+ ['key1', {sm: {s: 's', arr: [1, 2, 3]}}],
1474
+ ['key2', {sm: {s: 's', arr: [1, 2, 3]}}],
1475
+ ]),
1476
+ },
1477
+ ];
1478
+ return {rt, values};
1479
+ },
1480
+ },
1481
+ map_with_bigint_keys: {
1482
+ title: 'Map with bigint keys',
1483
+ getTestData: (dataOnly = false) => {
1484
+ const rt = dataOnly ? (null as any) : runType<Map<bigint, number>>();
1485
+ const values = [
1486
+ new Map<bigint, number>([
1487
+ [1n, 1],
1488
+ [2n, 2],
1489
+ [3n, 3],
1490
+ ]),
1491
+ ];
1492
+ return {rt, values};
1493
+ },
1494
+ },
1495
+ map_with_date_values: {
1496
+ title: 'Map with Date values',
1497
+ getTestData: (dataOnly = false) => {
1498
+ const rt = dataOnly ? (null as any) : runType<Map<string, Date>>();
1499
+ const values = [
1500
+ new Map<string, Date>([
1501
+ ['date1', new Date('2000-08-06T02:13:00.000Z')],
1502
+ ['date2', new Date('2001-09-07T03:14:00.000Z')],
1503
+ ]),
1504
+ ];
1505
+ return {rt, values};
1506
+ },
1507
+ },
1508
+ },
1509
+ CIRCULAR_REFS: {
1510
+ circular_types: {
1511
+ title: 'circular objects',
1512
+ getTestData: (dataOnly = false) => {
1513
+ type CircularObject = {
1514
+ name: string;
1515
+ child?: CircularObject;
1516
+ };
1517
+ const rt = dataOnly ? (null as any) : runType<CircularObject>();
1518
+ const values = [{name: 'hello', child: {name: 'world'}}];
1519
+ return {rt, values};
1520
+ },
1521
+ },
1522
+ circular_union_array: {
1523
+ title: 'CircularUnion array with discriminator',
1524
+ getTestData: (dataOnly = false) => {
1525
+ type CuArray = (CuArray | Date | number | string)[];
1526
+ const rt = dataOnly ? (null as any) : runType<CuArray>();
1527
+ const date = new Date('2000-08-06T02:13:00.000Z');
1528
+ const values = [
1529
+ [date, 123, 'hello', ['a', 'b', 'c']],
1530
+ [date, 123, 'hello', ['a', 2, 'c'], [date, 123, 'hello', ['a', 'b', 'c']]],
1531
+ [],
1532
+ ];
1533
+ return {rt, values};
1534
+ },
1535
+ },
1536
+ circular_tuple: {
1537
+ title: 'CircularTuple object with discriminator',
1538
+ getTestData: (dataOnly = false) => {
1539
+ interface CircularTuple {
1540
+ list: [bigint, CircularTuple?];
1541
+ }
1542
+ const rt = dataOnly ? (null as any) : runType<CircularTuple>();
1543
+ const values = [{list: [1n, {list: [2n, {list: [3n, {list: [4n]}]}]}]}, {list: [1n, {list: [2n]}]}, {list: [1n]}];
1544
+ return {rt, values};
1545
+ },
1546
+ },
1547
+ circular_index: {
1548
+ title: 'CircularIndex object with discriminator',
1549
+ getTestData: (dataOnly = false) => {
1550
+ interface CircularIndex {
1551
+ index: {[key: string]: CircularIndex};
1552
+ }
1553
+ const rt = dataOnly ? (null as any) : runType<CircularIndex>();
1554
+ const values = [{index: {a: {index: {b: {index: {}}}}}}, {index: {a: {index: {}}}}, {index: {}}];
1555
+ return {rt, values};
1556
+ },
1557
+ },
1558
+ circular_deep: {
1559
+ title: 'CircularDeep object with discriminator',
1560
+ getTestData: (dataOnly = false) => {
1561
+ interface CircularDeep {
1562
+ deep1: {deep2: {deep3: {deep4?: CircularDeep}}};
1563
+ }
1564
+ const rt = dataOnly ? (null as any) : runType<CircularDeep>();
1565
+ const values = [{deep1: {deep2: {deep3: {deep4: {deep1: {deep2: {deep3: {}}}}}}}}, {deep1: {deep2: {deep3: {}}}}];
1566
+ return {rt, values};
1567
+ },
1568
+ },
1569
+ circular_tuple_complex: {
1570
+ title: 'Circular tuple with complex structure',
1571
+ getTestData: (dataOnly = false) => {
1572
+ type CircularTupleComplex = [bigint, CircularTupleComplex?];
1573
+ const rt = dataOnly ? (null as any) : runType<CircularTupleComplex>();
1574
+ const values = [[1n, [2n, [3n, [4n]]]], [1n, [2n]], [1n]];
1575
+ return {rt, values};
1576
+ },
1577
+ },
1578
+ object_with_circular_array: {
1579
+ title: 'array strip extra params',
1580
+ getTestData: (dataOnly = false) => {
1581
+ const rt = dataOnly ? (null as any) : runType<ObjCircularArr>();
1582
+ const value: ObjCircularArr = {
1583
+ a: 'hello',
1584
+ deep: {
1585
+ b: 'world',
1586
+ c: 123,
1587
+ },
1588
+ d: [{a: 'hello2', deep: {b: 'world2', c: 1234}}],
1589
+ };
1590
+ const values = [value];
1591
+ return {rt, values};
1592
+ },
1593
+ },
1594
+ },
1595
+ TEMPLATE_LITERALS: {
1596
+ url_string: {
1597
+ title: 'template literal as string type, ie: `api/users/${number}`',
1598
+ getTestData: (dataOnly = false) => {
1599
+ type GetUserUrl = `api/users/${number}`;
1600
+ const rt = dataOnly ? (null as any) : runType<GetUserUrl>();
1601
+ const values: GetUserUrl[] = [
1602
+ 'api/users/0',
1603
+ 'api/users/1',
1604
+ 'api/users/42',
1605
+ 'api/users/-7',
1606
+ 'api/users/3.14',
1607
+ `api/users/${Number.MAX_SAFE_INTEGER}`,
1608
+ ];
1609
+ return {rt, values};
1610
+ },
1611
+ },
1612
+ url_in_object: {
1613
+ title: 'template literal as object property type',
1614
+ getTestData: (dataOnly = false) => {
1615
+ type ObjectWithTemplate = {
1616
+ url: `api/user/${number}`;
1617
+ method: string;
1618
+ };
1619
+ const rt = dataOnly ? (null as any) : runType<ObjectWithTemplate>();
1620
+ const values: ObjectWithTemplate[] = [
1621
+ {url: 'api/user/1', method: 'GET'},
1622
+ {url: 'api/user/42', method: 'POST'},
1623
+ {url: 'api/user/-7', method: 'DELETE'},
1624
+ ];
1625
+ return {rt, values};
1626
+ },
1627
+ },
1628
+ url_index_key: {
1629
+ title: 'template literal as index signature key',
1630
+ getTestData: (dataOnly = false) => {
1631
+ type Routes = {[key: `api/${string}`]: number};
1632
+ const rt = dataOnly ? (null as any) : runType<Routes>();
1633
+ const values: Routes[] = [{}, {'api/users': 1, 'api/posts': 2}, {'api/v1/users': 7, 'api/admin': 0}];
1634
+ return {rt, values};
1635
+ },
1636
+ },
1637
+ url_index_key_with_named: {
1638
+ title: 'template literal index key + sibling named property',
1639
+ getTestData: (dataOnly = false) => {
1640
+ type Routes = {meta: string; [key: `api/${string}`]: string | number};
1641
+ const rt = dataOnly ? (null as any) : runType<Routes>();
1642
+ const values: Routes[] = [{meta: 'a'}, {meta: 'b', 'api/users': 1}, {meta: 'c', 'api/users': 1, 'api/posts': 2}];
1643
+ return {rt, values};
1644
+ },
1645
+ },
1646
+ },
1647
+ OTHERS: {
1648
+ promise_jsonStringify_error: {
1649
+ title: 'throw error for Promise types',
1650
+ getTestData: (dataOnly = false) => {
1651
+ const rt = dataOnly ? (null as any) : runType<Promise<string>>();
1652
+ const values = []; // This test throws an error, so no values
1653
+ return {rt, values};
1654
+ },
1655
+ },
1656
+ non_serializable: {
1657
+ title: 'throw error for non-serializable types',
1658
+ getTestData: (dataOnly = false) => {
1659
+ const rt = dataOnly ? (null as any) : runType<Int8Array>();
1660
+ const values = []; // This test throws an error, so no values
1661
+ return {rt, values};
1662
+ },
1663
+ },
1664
+ non_serializable_interface: {
1665
+ title: 'throw error for non-serializable types in interfaces',
1666
+ getTestData: (dataOnly = false) => {
1667
+ const rt = dataOnly ? (null as any) : runType<{a: Int8Array}>();
1668
+ const values = []; // This test throws an error, so no values
1669
+ return {rt, values};
1670
+ },
1671
+ },
1672
+ non_serializable_array: {
1673
+ title: 'throw error for non-serializable types in arrays',
1674
+ getTestData: (dataOnly = false) => {
1675
+ const rt = dataOnly ? (null as any) : runType<Int8Array[]>();
1676
+ const values = []; // This test throws an error, so no values
1677
+ return {rt, values};
1678
+ },
1679
+ },
1680
+ non_serializable_tuple: {
1681
+ title: 'throw error for non-serializable types in tuples',
1682
+ getTestData: (dataOnly = false) => {
1683
+ const rt = dataOnly ? (null as any) : runType<[Int8Array]>();
1684
+ const values = []; // This test throws an error, so no values
1685
+ return {rt, values};
1686
+ },
1687
+ },
1688
+ },
1689
+ } satisfies TestSuite;