@scriptc/compiler 0.4.8 → 0.4.9

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 (536) hide show
  1. package/ambient/node-fallback/buffer.d.ts +2 -0
  2. package/ambient/node-fallback/child_process.d.ts +9 -3
  3. package/ambient/node-fallback/dns-promises.d.ts +25 -0
  4. package/ambient/node-fallback/dns.d.ts +29 -0
  5. package/ambient/node-fallback/test.d.ts +7 -0
  6. package/ambient/scriptc-node-fallback.d.ts +145 -2
  7. package/ambient/scriptc-overrides.d.ts +22 -13
  8. package/dist/backend/build-cache.d.ts +1 -1
  9. package/dist/backend/build-cache.js +1 -1
  10. package/dist/backend/build-cache.js.map +1 -1
  11. package/dist/backend/cache-root.d.ts +7 -0
  12. package/dist/backend/cache-root.js +27 -0
  13. package/dist/backend/cache-root.js.map +1 -1
  14. package/dist/backend/executable-features.js +5 -1
  15. package/dist/backend/executable-features.js.map +1 -1
  16. package/dist/backend/link-plan.js +7 -1
  17. package/dist/backend/link-plan.js.map +1 -1
  18. package/dist/backend/llvm/bytes-loop-versions.d.ts +12 -1
  19. package/dist/backend/llvm/bytes-loop-versions.js +107 -30
  20. package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
  21. package/dist/backend/llvm/bytes-loop-versions.test.js +96 -0
  22. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  23. package/dist/backend/llvm/checked-value-lifetimes.js +1 -0
  24. package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
  25. package/dist/backend/llvm/classes.d.ts +16 -5
  26. package/dist/backend/llvm/classes.js +34 -6
  27. package/dist/backend/llvm/classes.js.map +1 -1
  28. package/dist/backend/llvm/classes.test.js +21 -2
  29. package/dist/backend/llvm/classes.test.js.map +1 -1
  30. package/dist/backend/llvm/common.d.ts +9 -0
  31. package/dist/backend/llvm/common.js +9 -0
  32. package/dist/backend/llvm/common.js.map +1 -1
  33. package/dist/backend/llvm/cpu-dispatch.d.ts +36 -2
  34. package/dist/backend/llvm/cpu-dispatch.js +96 -2
  35. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  36. package/dist/backend/llvm/dense-array-access.d.ts +5 -2
  37. package/dist/backend/llvm/dense-array-access.js +16 -12
  38. package/dist/backend/llvm/dense-array-access.js.map +1 -1
  39. package/dist/backend/llvm/dense-array-access.test.js +3 -1
  40. package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
  41. package/dist/backend/llvm/dyn.d.ts +24 -0
  42. package/dist/backend/llvm/dyn.js +117 -3
  43. package/dist/backend/llvm/dyn.js.map +1 -1
  44. package/dist/backend/llvm/emit-function.js +6 -0
  45. package/dist/backend/llvm/emit-function.js.map +1 -1
  46. package/dist/backend/llvm/emit-journal.d.ts +1 -0
  47. package/dist/backend/llvm/emit-journal.js.map +1 -1
  48. package/dist/backend/llvm/emit-module.js +48 -5
  49. package/dist/backend/llvm/emit-module.js.map +1 -1
  50. package/dist/backend/llvm/emit-module.test.js +41 -0
  51. package/dist/backend/llvm/emit-module.test.js.map +1 -1
  52. package/dist/backend/llvm/emit-statements.js +11 -0
  53. package/dist/backend/llvm/emit-statements.js.map +1 -1
  54. package/dist/backend/llvm/emitter.d.ts +87 -7
  55. package/dist/backend/llvm/emitter.js +136 -15
  56. package/dist/backend/llvm/emitter.js.map +1 -1
  57. package/dist/backend/llvm/expr-async.js +28 -6
  58. package/dist/backend/llvm/expr-async.js.map +1 -1
  59. package/dist/backend/llvm/expr-containers.js +19 -5
  60. package/dist/backend/llvm/expr-containers.js.map +1 -1
  61. package/dist/backend/llvm/expr-dynamic.js +29 -1
  62. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  63. package/dist/backend/llvm/expr-primitives.js +104 -6
  64. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  65. package/dist/backend/llvm/expr-records.js +15 -1
  66. package/dist/backend/llvm/expr-records.js.map +1 -1
  67. package/dist/backend/llvm/expr-stream-bridges.js +53 -5
  68. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  69. package/dist/backend/llvm/inline-arrays.js +1 -1
  70. package/dist/backend/llvm/inline-arrays.js.map +1 -1
  71. package/dist/backend/llvm/js-ic.js +126 -2
  72. package/dist/backend/llvm/js-ic.js.map +1 -1
  73. package/dist/backend/llvm/lanes.d.ts +38 -0
  74. package/dist/backend/llvm/lanes.js +778 -0
  75. package/dist/backend/llvm/lanes.js.map +1 -0
  76. package/dist/backend/llvm/lanes.test.d.ts +1 -0
  77. package/dist/backend/llvm/lanes.test.js +402 -0
  78. package/dist/backend/llvm/lanes.test.js.map +1 -0
  79. package/dist/backend/llvm/lib-dispatch.js +9 -4
  80. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  81. package/dist/backend/llvm/lib-network.js +20 -0
  82. package/dist/backend/llvm/lib-network.js.map +1 -1
  83. package/dist/backend/llvm/lib-shared.js +27 -0
  84. package/dist/backend/llvm/lib-shared.js.map +1 -1
  85. package/dist/backend/llvm/lib-test.js +11 -0
  86. package/dist/backend/llvm/lib-test.js.map +1 -1
  87. package/dist/backend/llvm/local-array-reads.js +2 -2
  88. package/dist/backend/llvm/local-array-reads.js.map +1 -1
  89. package/dist/backend/llvm/map-number-lookup.js +8 -2
  90. package/dist/backend/llvm/map-number-lookup.js.map +1 -1
  91. package/dist/backend/llvm/nullable-unions.js +5 -2
  92. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  93. package/dist/backend/llvm/publish.d.ts +3 -0
  94. package/dist/backend/llvm/publish.js +2 -2
  95. package/dist/backend/llvm/publish.js.map +1 -1
  96. package/dist/backend/llvm/reference-writes.js +1 -0
  97. package/dist/backend/llvm/reference-writes.js.map +1 -1
  98. package/dist/backend/llvm/region-groups.js +43 -4
  99. package/dist/backend/llvm/region-groups.js.map +1 -1
  100. package/dist/backend/llvm/region-groups.test.js +79 -0
  101. package/dist/backend/llvm/region-groups.test.js.map +1 -1
  102. package/dist/backend/llvm/runtime-registries.test.js +32 -1
  103. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  104. package/dist/backend/llvm/shapes.js +10 -1
  105. package/dist/backend/llvm/shapes.js.map +1 -1
  106. package/dist/backend/llvm/string-reads.d.ts +1 -1
  107. package/dist/backend/llvm/string-reads.js +1 -1
  108. package/dist/backend/llvm/string-reads.js.map +1 -1
  109. package/dist/backend/llvm/unwind-abi.js +24 -2
  110. package/dist/backend/llvm/unwind-abi.js.map +1 -1
  111. package/dist/backend/llvm/unwind-abi.test.js +38 -0
  112. package/dist/backend/llvm/unwind-abi.test.js.map +1 -1
  113. package/dist/backend/llvm/walkers.d.ts +3 -0
  114. package/dist/backend/llvm/walkers.js +20 -2
  115. package/dist/backend/llvm/walkers.js.map +1 -1
  116. package/dist/backend/native/contracts.d.ts +15 -3
  117. package/dist/backend/native/executable.js +19 -5
  118. package/dist/backend/native/executable.js.map +1 -1
  119. package/dist/backend/native-codegen-core.d.ts +20 -0
  120. package/dist/backend/native-codegen-core.js +15 -0
  121. package/dist/backend/native-codegen-core.js.map +1 -1
  122. package/dist/backend/native-codegen.d.ts +5 -0
  123. package/dist/backend/native-codegen.js +62 -8
  124. package/dist/backend/native-codegen.js.map +1 -1
  125. package/dist/backend/native-codegen.test.js +48 -8
  126. package/dist/backend/native-codegen.test.js.map +1 -1
  127. package/dist/backend/native-link-info-core.d.ts +27 -3
  128. package/dist/backend/native-link-info-core.js.map +1 -1
  129. package/dist/backend/native-link-info.test.js +17 -1
  130. package/dist/backend/native-link-info.test.js.map +1 -1
  131. package/dist/backend/native-toolchain.d.ts +1 -1
  132. package/dist/backend/native-toolchain.js +1 -1
  133. package/dist/backend/native-toolchain.js.map +1 -1
  134. package/dist/backend/native-toolchain.test.js +14 -1
  135. package/dist/backend/native-toolchain.test.js.map +1 -1
  136. package/dist/backend/runtime-pack-core.d.ts +9 -3
  137. package/dist/backend/runtime-pack-core.js +6 -1
  138. package/dist/backend/runtime-pack-core.js.map +1 -1
  139. package/dist/backend/runtime-pack.test.js +32 -1
  140. package/dist/backend/runtime-pack.test.js.map +1 -1
  141. package/dist/backend/targets.d.ts +9 -1
  142. package/dist/backend/targets.js +11 -2
  143. package/dist/backend/targets.js.map +1 -1
  144. package/dist/backend/targets.test.js +6 -0
  145. package/dist/backend/targets.test.js.map +1 -1
  146. package/dist/cli/command.js +15 -1
  147. package/dist/cli/command.js.map +1 -1
  148. package/dist/cli/host.d.ts +6 -0
  149. package/dist/cli/mcp.d.ts +72 -0
  150. package/dist/cli/mcp.js +601 -0
  151. package/dist/cli/mcp.js.map +1 -0
  152. package/dist/cli/mcp.test.d.ts +1 -0
  153. package/dist/cli/mcp.test.js +380 -0
  154. package/dist/cli/mcp.test.js.map +1 -0
  155. package/dist/cli/output-options.d.ts +1 -0
  156. package/dist/cli/output-options.js +3 -0
  157. package/dist/cli/output-options.js.map +1 -1
  158. package/dist/cli/usage.d.ts +51 -1
  159. package/dist/cli/usage.js +709 -186
  160. package/dist/cli/usage.js.map +1 -1
  161. package/dist/compat/fetch-profile.js +9 -4
  162. package/dist/compat/fetch-profile.js.map +1 -1
  163. package/dist/compile-types.d.ts +17 -0
  164. package/dist/coverage/report.d.ts +5 -9
  165. package/dist/coverage/report.js.map +1 -1
  166. package/dist/executable/executable-cache.d.ts +17 -3
  167. package/dist/executable/executable-cache.js +17 -3
  168. package/dist/executable/executable-cache.js.map +1 -1
  169. package/dist/executable/prepare.js +87 -10
  170. package/dist/executable/prepare.js.map +1 -1
  171. package/dist/frontend/analysis.js +3 -2
  172. package/dist/frontend/analysis.js.map +1 -1
  173. package/dist/frontend/canon-map.js +13 -8
  174. package/dist/frontend/canon-map.js.map +1 -1
  175. package/dist/frontend/decl-projection.d.ts +18 -0
  176. package/dist/frontend/decl-projection.js +90 -22
  177. package/dist/frontend/decl-projection.js.map +1 -1
  178. package/dist/frontend/decl-projection.test.js +47 -1
  179. package/dist/frontend/decl-projection.test.js.map +1 -1
  180. package/dist/frontend/default-library.d.ts +10 -0
  181. package/dist/frontend/default-library.js +43 -0
  182. package/dist/frontend/default-library.js.map +1 -0
  183. package/dist/frontend/fork-target.js +54 -9
  184. package/dist/frontend/fork-target.js.map +1 -1
  185. package/dist/frontend/fork-target.test.js +82 -0
  186. package/dist/frontend/fork-target.test.js.map +1 -1
  187. package/dist/frontend/inferred-js-diagnostics.test.js +73 -0
  188. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  189. package/dist/frontend/lowering/abstract-equality.d.ts +2 -1
  190. package/dist/frontend/lowering/abstract-equality.js +7 -1
  191. package/dist/frontend/lowering/abstract-equality.js.map +1 -1
  192. package/dist/frontend/lowering/array-values.js +2 -2
  193. package/dist/frontend/lowering/array-values.js.map +1 -1
  194. package/dist/frontend/lowering/assertion-members.js +52 -2
  195. package/dist/frontend/lowering/assertion-members.js.map +1 -1
  196. package/dist/frontend/lowering/builtin-namespaces.d.ts +5 -0
  197. package/dist/frontend/lowering/builtin-namespaces.js +19 -12
  198. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  199. package/dist/frontend/lowering/builtins/callable-aliases.js +42 -6
  200. package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
  201. package/dist/frontend/lowering/builtins/child-process.d.ts +12 -11
  202. package/dist/frontend/lowering/builtins/child-process.js +235 -38
  203. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  204. package/dist/frontend/lowering/builtins/compression.d.ts +6 -1
  205. package/dist/frontend/lowering/builtins/compression.js +3 -3
  206. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  207. package/dist/frontend/lowering/builtins/constants.js +2 -2
  208. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  209. package/dist/frontend/lowering/builtins/crypto.d.ts +3 -1
  210. package/dist/frontend/lowering/builtins/crypto.js +9 -1
  211. package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
  212. package/dist/frontend/lowering/builtins/dates.js +26 -6
  213. package/dist/frontend/lowering/builtins/dates.js.map +1 -1
  214. package/dist/frontend/lowering/builtins/environment.d.ts +13 -1
  215. package/dist/frontend/lowering/builtins/environment.js +15 -4
  216. package/dist/frontend/lowering/builtins/environment.js.map +1 -1
  217. package/dist/frontend/lowering/builtins/module-bindings.d.ts +33 -0
  218. package/dist/frontend/lowering/builtins/module-bindings.js +213 -11
  219. package/dist/frontend/lowering/builtins/module-bindings.js.map +1 -1
  220. package/dist/frontend/lowering/builtins/module-resolution.d.ts +9 -2
  221. package/dist/frontend/lowering/builtins/module-resolution.js +187 -19
  222. package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
  223. package/dist/frontend/lowering/builtins/performance.js +1 -1
  224. package/dist/frontend/lowering/builtins/performance.js.map +1 -1
  225. package/dist/frontend/lowering/builtins/process.js +40 -2
  226. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  227. package/dist/frontend/lowering/builtins/promises.js +33 -0
  228. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  229. package/dist/frontend/lowering/builtins/readline.d.ts +9 -5
  230. package/dist/frontend/lowering/builtins/readline.js +184 -75
  231. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  232. package/dist/frontend/lowering/builtins/url.d.ts +4 -0
  233. package/dist/frontend/lowering/builtins/url.js +6 -0
  234. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  235. package/dist/frontend/lowering/call-arguments.js +15 -0
  236. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  237. package/dist/frontend/lowering/callable-properties.d.ts +34 -0
  238. package/dist/frontend/lowering/callable-properties.js +210 -0
  239. package/dist/frontend/lowering/callable-properties.js.map +1 -0
  240. package/dist/frontend/lowering/cjs-inline-require.d.ts +16 -0
  241. package/dist/frontend/lowering/cjs-inline-require.js +105 -0
  242. package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
  243. package/dist/frontend/lowering/cjs-inline-require.test.d.ts +1 -0
  244. package/dist/frontend/lowering/cjs-inline-require.test.js +61 -0
  245. package/dist/frontend/lowering/cjs-inline-require.test.js.map +1 -0
  246. package/dist/frontend/lowering/class-dynamic-dispatch.js +82 -2
  247. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  248. package/dist/frontend/lowering/class-protocols.d.ts +57 -4
  249. package/dist/frontend/lowering/class-protocols.js +597 -30
  250. package/dist/frontend/lowering/class-protocols.js.map +1 -1
  251. package/dist/frontend/lowering/class-unions.js +2 -2
  252. package/dist/frontend/lowering/class-unions.js.map +1 -1
  253. package/dist/frontend/lowering/coercions/function-adapters.d.ts +12 -0
  254. package/dist/frontend/lowering/coercions/function-adapters.js +62 -0
  255. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  256. package/dist/frontend/lowering/coercions/structural-plans.js +56 -1
  257. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  258. package/dist/frontend/lowering/coercions/structural.js +9 -4
  259. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  260. package/dist/frontend/lowering/collection-ingestion.d.ts +9 -0
  261. package/dist/frontend/lowering/collection-ingestion.js +115 -41
  262. package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
  263. package/dist/frontend/lowering/containers/array-callbacks.js +16 -0
  264. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  265. package/dist/frontend/lowering/containers/bytes.js +66 -10
  266. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  267. package/dist/frontend/lowering/containers/collection-methods.js +61 -5
  268. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  269. package/dist/frontend/lowering/containers/filter-predicates.js +11 -0
  270. package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
  271. package/dist/frontend/lowering/containers/indexed-objects.d.ts +15 -0
  272. package/dist/frontend/lowering/containers/indexed-objects.js +213 -30
  273. package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
  274. package/dist/frontend/lowering/error-name-order.d.ts +16 -0
  275. package/dist/frontend/lowering/error-name-order.js +61 -0
  276. package/dist/frontend/lowering/error-name-order.js.map +1 -1
  277. package/dist/frontend/lowering/expressions/asserted-receiver.d.ts +17 -0
  278. package/dist/frontend/lowering/expressions/asserted-receiver.js +123 -1
  279. package/dist/frontend/lowering/expressions/asserted-receiver.js.map +1 -1
  280. package/dist/frontend/lowering/expressions/binary.js +147 -20
  281. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  282. package/dist/frontend/lowering/expressions/element-access.js +63 -14
  283. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  284. package/dist/frontend/lowering/expressions/erased-delete.d.ts +59 -0
  285. package/dist/frontend/lowering/expressions/erased-delete.js +247 -0
  286. package/dist/frontend/lowering/expressions/erased-delete.js.map +1 -0
  287. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +10 -0
  288. package/dist/frontend/lowering/expressions/hosted-narrowing.js +48 -1
  289. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  290. package/dist/frontend/lowering/expressions/identifiers.js +20 -0
  291. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  292. package/dist/frontend/lowering/expressions/narrowing.d.ts +7 -2
  293. package/dist/frontend/lowering/expressions/narrowing.js +77 -45
  294. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  295. package/dist/frontend/lowering/expressions/object-literals.js +62 -19
  296. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  297. package/dist/frontend/lowering/expressions/optional-chains.js +19 -0
  298. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  299. package/dist/frontend/lowering/expressions/property-access.d.ts +7 -7
  300. package/dist/frontend/lowering/expressions/property-access.js +247 -48
  301. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  302. package/dist/frontend/lowering/expressions/relational.d.ts +1 -0
  303. package/dist/frontend/lowering/expressions/relational.js +18 -8
  304. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  305. package/dist/frontend/lowering/expressions/union-fields.js +11 -5
  306. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  307. package/dist/frontend/lowering/expressions/updates.js +121 -11
  308. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  309. package/dist/frontend/lowering/function-context.d.ts +10 -0
  310. package/dist/frontend/lowering/function-context.js +36 -0
  311. package/dist/frontend/lowering/function-context.js.map +1 -1
  312. package/dist/frontend/lowering/function-returns.js +8 -8
  313. package/dist/frontend/lowering/function-returns.js.map +1 -1
  314. package/dist/frontend/lowering/handle-properties.d.ts +62 -3
  315. package/dist/frontend/lowering/handle-properties.js +674 -26
  316. package/dist/frontend/lowering/handle-properties.js.map +1 -1
  317. package/dist/frontend/lowering/handle-properties.test.js +95 -2
  318. package/dist/frontend/lowering/handle-properties.test.js.map +1 -1
  319. package/dist/frontend/lowering/lower-builtin-values.d.ts +12 -0
  320. package/dist/frontend/lowering/lower-builtin-values.js +44 -0
  321. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  322. package/dist/frontend/lowering/lower-calls.js +328 -136
  323. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  324. package/dist/frontend/lowering/lower-classes.js +82 -17
  325. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  326. package/dist/frontend/lowering/lower-event-emitter.js +113 -9
  327. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  328. package/dist/frontend/lowering/lower-expando.d.ts +13 -21
  329. package/dist/frontend/lowering/lower-expando.js +90 -126
  330. package/dist/frontend/lowering/lower-expando.js.map +1 -1
  331. package/dist/frontend/lowering/lower-exprs.js +2 -2
  332. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  333. package/dist/frontend/lowering/lower-functions.js +65 -0
  334. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  335. package/dist/frontend/lowering/lower-inspect.js +471 -0
  336. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  337. package/dist/frontend/lowering/lower-modules.js +36 -10
  338. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  339. package/dist/frontend/lowering/lower-node-island.js +28 -0
  340. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  341. package/dist/frontend/lowering/lower-server.d.ts +53 -7
  342. package/dist/frontend/lowering/lower-server.js +213 -42
  343. package/dist/frontend/lowering/lower-server.js.map +1 -1
  344. package/dist/frontend/lowering/lower-stdlib.js +50 -7
  345. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  346. package/dist/frontend/lowering/lower-stmts.d.ts +24 -0
  347. package/dist/frontend/lowering/lower-stmts.js +463 -220
  348. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  349. package/dist/frontend/lowering/lower-stream.js +2 -2
  350. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  351. package/dist/frontend/lowering/lower-test.js +71 -2
  352. package/dist/frontend/lowering/lower-test.js.map +1 -1
  353. package/dist/frontend/lowering/lowerer.d.ts +81 -10
  354. package/dist/frontend/lowering/lowerer.js +319 -72
  355. package/dist/frontend/lowering/lowerer.js.map +1 -1
  356. package/dist/frontend/lowering/new-target.js +10 -2
  357. package/dist/frontend/lowering/new-target.js.map +1 -1
  358. package/dist/frontend/lowering/nullish-empty-pattern.js +3 -3
  359. package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -1
  360. package/dist/frontend/lowering/partial-assertions.js +30 -5
  361. package/dist/frontend/lowering/partial-assertions.js.map +1 -1
  362. package/dist/frontend/lowering/primitive-throws.js +91 -1
  363. package/dist/frontend/lowering/primitive-throws.js.map +1 -1
  364. package/dist/frontend/lowering/primitive-wrappers.d.ts +9 -0
  365. package/dist/frontend/lowering/primitive-wrappers.js +2 -2
  366. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
  367. package/dist/frontend/lowering/promise-executor-adapter.js +5 -2
  368. package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
  369. package/dist/frontend/lowering/record-links.js +7 -2
  370. package/dist/frontend/lowering/record-links.js.map +1 -1
  371. package/dist/frontend/lowering/surfaces.d.ts +4 -0
  372. package/dist/frontend/lowering/surfaces.js +118 -2
  373. package/dist/frontend/lowering/surfaces.js.map +1 -1
  374. package/dist/frontend/lowering/surfaces.test.d.ts +1 -0
  375. package/dist/frontend/lowering/surfaces.test.js +31 -0
  376. package/dist/frontend/lowering/surfaces.test.js.map +1 -0
  377. package/dist/frontend/mock-shapes.js +3 -3
  378. package/dist/frontend/mock-shapes.js.map +1 -1
  379. package/dist/frontend/npm-static-ladder.d.ts +21 -0
  380. package/dist/frontend/npm-static-ladder.js +2 -0
  381. package/dist/frontend/npm-static-ladder.js.map +1 -0
  382. package/dist/frontend/npm-static-ladder.test.d.ts +1 -0
  383. package/dist/frontend/npm-static-ladder.test.js +138 -0
  384. package/dist/frontend/npm-static-ladder.test.js.map +1 -0
  385. package/dist/frontend/npm-static-status.d.ts +15 -0
  386. package/dist/frontend/npm-static-status.js +2 -0
  387. package/dist/frontend/npm-static-status.js.map +1 -0
  388. package/dist/frontend/package-shims.js +1 -1
  389. package/dist/frontend/package-shims.js.map +1 -1
  390. package/dist/frontend/pipeline.d.ts +1 -1
  391. package/dist/frontend/pipeline.js +222 -25
  392. package/dist/frontend/pipeline.js.map +1 -1
  393. package/dist/frontend/program-analysis.d.ts +4 -0
  394. package/dist/frontend/program-analysis.js +6 -0
  395. package/dist/frontend/program-analysis.js.map +1 -1
  396. package/dist/frontend/program.js +258 -32
  397. package/dist/frontend/program.js.map +1 -1
  398. package/dist/frontend/program.test.js +30 -0
  399. package/dist/frontend/program.test.js.map +1 -1
  400. package/dist/frontend/resolve.js +29 -5
  401. package/dist/frontend/resolve.js.map +1 -1
  402. package/dist/frontend/resolve.test.js +40 -0
  403. package/dist/frontend/resolve.test.js.map +1 -1
  404. package/dist/frontend/services.d.ts +8 -0
  405. package/dist/frontend/services.js +7 -0
  406. package/dist/frontend/services.js.map +1 -1
  407. package/dist/frontend/ts7/checker.d.ts +7 -0
  408. package/dist/frontend/ts7/checker.js +12 -0
  409. package/dist/frontend/ts7/checker.js.map +1 -1
  410. package/dist/frontend/ts7/checker.test.js +1 -0
  411. package/dist/frontend/ts7/checker.test.js.map +1 -1
  412. package/dist/frontend/ts7/program-host.d.ts +39 -2
  413. package/dist/frontend/ts7/program-host.js +62 -8
  414. package/dist/frontend/ts7/program-host.js.map +1 -1
  415. package/dist/frontend/ts7/program-host.test.js +33 -0
  416. package/dist/frontend/ts7/program-host.test.js.map +1 -1
  417. package/dist/frontend/ts7/session-cache.d.ts +5 -1
  418. package/dist/frontend/ts7/session-cache.js +7 -1
  419. package/dist/frontend/ts7/session-cache.js.map +1 -1
  420. package/dist/frontend/ts7/session-cache.test.js +37 -0
  421. package/dist/frontend/ts7/session-cache.test.js.map +1 -1
  422. package/dist/frontend/ts7/session.js +19 -1
  423. package/dist/frontend/ts7/session.js.map +1 -1
  424. package/dist/frontend/ts7/source-parser.d.ts +17 -2
  425. package/dist/frontend/ts7/source-parser.js +61 -2
  426. package/dist/frontend/ts7/source-parser.js.map +1 -1
  427. package/dist/frontend/ts7/source-parser.test.js +55 -2
  428. package/dist/frontend/ts7/source-parser.test.js.map +1 -1
  429. package/dist/frontend/tsc-codes.d.ts +3 -2
  430. package/dist/frontend/tsc-codes.js +129 -22
  431. package/dist/frontend/tsc-codes.js.map +1 -1
  432. package/dist/frontend/type-mapper.d.ts +5 -11
  433. package/dist/frontend/type-mapper.js +380 -70
  434. package/dist/frontend/type-mapper.js.map +1 -1
  435. package/dist/index.d.ts +1 -1
  436. package/dist/index.js +67 -7
  437. package/dist/index.js.map +1 -1
  438. package/dist/ir/builtin-effects.js +29 -0
  439. package/dist/ir/builtin-effects.js.map +1 -1
  440. package/dist/ir/builtin-signatures.d.ts +1 -1
  441. package/dist/ir/builtin-signatures.js +72 -6
  442. package/dist/ir/builtin-signatures.js.map +1 -1
  443. package/dist/ir/codec.generated.d.ts +1 -1
  444. package/dist/ir/codec.generated.js +321 -263
  445. package/dist/ir/codec.generated.js.map +1 -1
  446. package/dist/ir/constant-length-clones.d.ts +26 -0
  447. package/dist/ir/constant-length-clones.js +589 -0
  448. package/dist/ir/constant-length-clones.js.map +1 -0
  449. package/dist/ir/constant-length-clones.test.d.ts +1 -0
  450. package/dist/ir/constant-length-clones.test.js +292 -0
  451. package/dist/ir/constant-length-clones.test.js.map +1 -0
  452. package/dist/ir/constant-tables.d.ts +10 -5
  453. package/dist/ir/constant-tables.js +83 -17
  454. package/dist/ir/constant-tables.js.map +1 -1
  455. package/dist/ir/constant-tables.test.js +58 -1
  456. package/dist/ir/constant-tables.test.js.map +1 -1
  457. package/dist/ir/fields.generated.js +5 -2
  458. package/dist/ir/fields.generated.js.map +1 -1
  459. package/dist/ir/function-references.js +2 -0
  460. package/dist/ir/function-references.js.map +1 -1
  461. package/dist/ir/function-references.test.js +13 -0
  462. package/dist/ir/function-references.test.js.map +1 -1
  463. package/dist/ir/integer-loops.js +1 -0
  464. package/dist/ir/integer-loops.js.map +1 -1
  465. package/dist/ir/integer-loops.test.js +16 -0
  466. package/dist/ir/integer-loops.test.js.map +1 -1
  467. package/dist/ir/ir.d.ts +50 -6
  468. package/dist/ir/ir.js +44 -2
  469. package/dist/ir/ir.js.map +1 -1
  470. package/dist/ir/ir.test.js +83 -1
  471. package/dist/ir/ir.test.js.map +1 -1
  472. package/dist/ir/js-groups.js +5 -1
  473. package/dist/ir/js-groups.js.map +1 -1
  474. package/dist/ir/js-ic.d.ts +20 -0
  475. package/dist/ir/js-ic.js +81 -4
  476. package/dist/ir/js-ic.js.map +1 -1
  477. package/dist/ir/js-ic.test.js +8 -1
  478. package/dist/ir/js-ic.test.js.map +1 -1
  479. package/dist/ir/lane-plans.d.ts +86 -0
  480. package/dist/ir/lane-plans.js +589 -0
  481. package/dist/ir/lane-plans.js.map +1 -0
  482. package/dist/ir/lane-plans.test.d.ts +1 -0
  483. package/dist/ir/lane-plans.test.js +549 -0
  484. package/dist/ir/lane-plans.test.js.map +1 -0
  485. package/dist/ir/runtime-features.d.ts +68 -10
  486. package/dist/ir/runtime-features.js +285 -17
  487. package/dist/ir/runtime-features.js.map +1 -1
  488. package/dist/ir/runtime-features.test.js +190 -1
  489. package/dist/ir/runtime-features.test.js.map +1 -1
  490. package/dist/ir/validate.js +61 -24
  491. package/dist/ir/validate.js.map +1 -1
  492. package/dist/native/cache.d.ts +5 -0
  493. package/dist/native/cache.js +23 -1
  494. package/dist/native/cache.js.map +1 -1
  495. package/dist/native/cache.test.js +29 -1
  496. package/dist/native/cache.test.js.map +1 -1
  497. package/dist/native/cli.js +4 -2
  498. package/dist/native/cli.js.map +1 -1
  499. package/dist/native/compiler.d.ts +11 -3
  500. package/dist/native/compiler.js +102 -16
  501. package/dist/native/compiler.js.map +1 -1
  502. package/dist/native/compiler.test.js +244 -2
  503. package/dist/native/compiler.test.js.map +1 -1
  504. package/dist/native/prepare.d.ts +14 -1
  505. package/dist/native/prepare.js +79 -29
  506. package/dist/native/prepare.js.map +1 -1
  507. package/dist/native/sanitizer.test.js +3 -0
  508. package/dist/native/sanitizer.test.js.map +1 -1
  509. package/dist/native/unchanged.d.ts +80 -0
  510. package/dist/native/unchanged.js +301 -0
  511. package/dist/native/unchanged.js.map +1 -0
  512. package/dist/native/unchanged.test.d.ts +1 -0
  513. package/dist/native/unchanged.test.js +249 -0
  514. package/dist/native/unchanged.test.js.map +1 -0
  515. package/dist/node-islands/boundary.d.ts +16 -0
  516. package/dist/node-islands/boundary.js +70 -7
  517. package/dist/node-islands/boundary.js.map +1 -1
  518. package/dist/node-islands/boundary.test.js +59 -14
  519. package/dist/node-islands/boundary.test.js.map +1 -1
  520. package/dist/node-islands/detect.js +203 -47
  521. package/dist/node-islands/detect.js.map +1 -1
  522. package/dist/node-islands/detect.test.js +45 -0
  523. package/dist/node-islands/detect.test.js.map +1 -1
  524. package/dist/node-islands/growth.js +4 -16
  525. package/dist/node-islands/growth.js.map +1 -1
  526. package/dist/node-islands/modules.d.ts +3 -0
  527. package/dist/node-islands/modules.js +143 -12
  528. package/dist/node-islands/modules.js.map +1 -1
  529. package/dist/node-islands/modules.test.js +125 -0
  530. package/dist/node-islands/modules.test.js.map +1 -1
  531. package/dist/node-islands/report.d.ts +1 -1
  532. package/dist/node-islands/report.js +2 -1
  533. package/dist/node-islands/report.js.map +1 -1
  534. package/package.json +20 -20
  535. package/shims/undici/core/request.ts +7 -1
  536. package/surface-manifest.json +380 -2
@@ -4,7 +4,7 @@ import { contentDigest } from "./lowering/unit-journal.js";
4
4
  import { mockCallRecordType, mockContextType } from "./mock-shapes.js";
5
5
  import * as ts from "./ts7/adapter.js";
6
6
  import { bodyReadsArguments } from "./arguments-usage.js";
7
- import { BYTES_ELEMENT_NAME, arrayOf, isDynTypedRefType, BOOL, bytesOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, FOREIGN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, iterableArmsElem, isUnitType, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, ZLIB_STREAM_MODES, setOf, STRING, SYMBOL_T, typeEquals, typeKey, maybePromiseUnionArmsOk, unionContainerArmsOk, UNDEFINED_T, VOID, } from "../ir/ir.js";
7
+ import { BYTES_ELEMENT_NAME, arrayOf, isDynTypedRefType, BOOL, bytesOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, CHILD_T, CRYPTOHASH_T, CRYPTOHMAC_T, DATE_T, DYN, FOREIGN, F64, funcOf, isSupportedArrayElem, isSupportedIndexValue, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, iterableArmsElem, isUnitType, mapOf, NULL_T, PROCSTREAM_T, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, ZLIB_STREAM_MODES, setOf, STRING, SYMBOL_T, typeEquals, sortArms, typeKey, maybePromiseUnionArmsOk, unionContainerArmsOk, UNDEFINED_T, VOID, } from "../ir/ir.js";
8
8
  import { BIGINT_T, KEY_ORDER_FIELD } from "../ir/ir.js";
9
9
  import { literalValues } from "./literal-values.js";
10
10
  import { remapUnionDiscriminant } from "./union-discriminants.js";
@@ -299,7 +299,11 @@ export class ShapeRegistry {
299
299
  keyOf(fields, tuple, indexValue) {
300
300
  return ((tuple ? "tuple!" : "") +
301
301
  (indexValue ? `idx<${typeKey(indexValue)}>!` : "") +
302
- JSON.stringify(fields.map((f) => [f.name, typeKey(f.type)])));
302
+ // An absentable optional dyn field carries a third element in the
303
+ // key; every other entry keeps the historical two-element spelling,
304
+ // so a shape without one hashes exactly as before (zero-cost
305
+ // identity for programs that use no optional `unknown`/`any`).
306
+ JSON.stringify(fields.map((f) => f.optional === true ? [f.name, typeKey(f.type), 1] : [f.name, typeKey(f.type)])));
303
307
  }
304
308
  /** Runs one lowering unit under its historical emit-order rank. Shape
305
309
  * ids remain demand-assigned; only first-seen declaration-order metadata
@@ -1336,6 +1340,15 @@ function genChannels(yieldTs, retTs, nextTs, ctx) {
1336
1340
  * fallback for it. */
1337
1341
  const MAP_TYPE_MAX_DEPTH = 64;
1338
1342
  let mapTypeDepth = 0;
1343
+ /** The overload sets whose signatures the equal-modulo-union-order arm is
1344
+ * mapping, outermost first. Mapping a signature maps its parameter and return
1345
+ * types, which can name the set again — `interface R { (x: number): R; (x:
1346
+ * string): R }` declared in a package, which isOverloadedCallableMemberType
1347
+ * does not claim. Each level would map every signature again, so a recursive
1348
+ * set expands exponentially until MAP_TYPE_MAX_DEPTH cuts every branch off. A
1349
+ * set already being expanded is refused instead (null, as every other
1350
+ * unmappable type), and the slot reports the overload diagnostic. */
1351
+ const overloadExpansion = [];
1339
1352
  /** Bumped whenever mapType resolves a type through CONTEXT-SENSITIVE or
1340
1353
  * collection-sensitive hooks (a generic body's type parameter, a mixin
1341
1354
  * instantiation, a generic class instance) — mappings that can make the same
@@ -2347,7 +2360,7 @@ function mapTypeInner(type, ctx) {
2347
2360
  }
2348
2361
  if (hasNum && hasStr) {
2349
2362
  const arms = [F64, STRING];
2350
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
2363
+ sortArms(arms);
2351
2364
  return { kind: "union", unionId: unions.intern(arms) };
2352
2365
  }
2353
2366
  return hasStr ? STRING : F64;
@@ -2982,7 +2995,9 @@ function mapTypeInner(type, ctx) {
2982
2995
  // in a declaration file, which recordProvenanceOk rightly refuses for
2983
2996
  // lib type worlds. Map it manually with the executor's own scriptc
2984
2997
  // field shapes (plain-value resolve — () => void for Promise<void> —
2985
- // and the Error-pinned reject), so both the destructured and the
2998
+ // and the reject the promise's own reason representation picks: Error
2999
+ // for a typed payload, the checked-dynamic value for a promise whose
3000
+ // settled value is unknown), so both the destructured and the
2986
3001
  // record-holding binding forms compile. User-declared literals with
2987
3002
  // these member names keep the ordinary record path (their declarations
2988
3003
  // are not in declaration files).
@@ -3005,7 +3020,7 @@ function mapTypeInner(type, ctx) {
3005
3020
  name: "reject",
3006
3021
  type: {
3007
3022
  kind: "func",
3008
- params: [{ kind: "object", className: "%Error" }],
3023
+ params: [inner.kind === "dyn" ? DYN : { kind: "object", className: "%Error" }],
3009
3024
  ret: VOID,
3010
3025
  },
3011
3026
  },
@@ -3302,7 +3317,8 @@ function mapTypeInner(type, ctx) {
3302
3317
  isStdlibInterface("SharedArrayBuffer") ||
3303
3318
  isStdlibInterface("PropertyDescriptor") ||
3304
3319
  isStdlibInterface("ProcessVersions") ||
3305
- isStdlibInterface("ProcessRelease"))
3320
+ isStdlibInterface("ProcessRelease") ||
3321
+ isStdlibInterface("ProcessReport"))
3306
3322
  return DYN;
3307
3323
  if (Object.values(BYTES_ELEMENT_NAME).some((name) => isStdlibInterface(`${name}Constructor`)))
3308
3324
  return DYN;
@@ -3965,7 +3981,7 @@ function mapTypeInner(type, ctx) {
3965
3981
  const optStr = withUndefinedArm(STRING, ctx.unions);
3966
3982
  const optNum = withUndefinedArm(F64, ctx.unions);
3967
3983
  const optBool = withUndefinedArm(BOOL, ctx.unions);
3968
- const stdioArms = [arrayOf(STRING), STRING, UNDEFINED_T].sort((a, b) => typeKey(a) < typeKey(b) ? -1 : 1);
3984
+ const stdioArms = sortArms([arrayOf(STRING), STRING, UNDEFINED_T]);
3969
3985
  const stdio = { kind: "union", unionId: ctx.unions.intern(stdioArms) };
3970
3986
  if (!optStr || !optNum || !optBool)
3971
3987
  return null;
@@ -3998,19 +4014,25 @@ function mapTypeInner(type, ctx) {
3998
4014
  const optBool = withUndefinedArm(BOOL, ctx.unions);
3999
4015
  const stdioArms = [arrayOf(STRING), STRING, UNDEFINED_T].sort((a, b) => typeKey(a) < typeKey(b) ? -1 : 1);
4000
4016
  const stdio = { kind: "union", unionId: ctx.unions.intern(stdioArms) };
4001
- if (!optStr || !optNum || !optBool)
4017
+ // `env?: NodeJS.ProcessEnv` — the same record the inline literal builds
4018
+ // its [k,v,...] pairs from. A runtime record can carry a replacement
4019
+ // environment, so the member maps rather than staying literal-only.
4020
+ const envProp = ctx.checker.getPropertyOfType(type, "env");
4021
+ const env = envProp ? mapType(ctx.checker.getTypeOfSymbol(envProp), ctx) : null;
4022
+ if (!optStr || !optNum || !optBool || !env || env.kind !== "union")
4002
4023
  return null;
4003
4024
  return {
4004
4025
  kind: "record",
4005
4026
  shapeId: ctx.shapes.intern([
4006
4027
  { name: "cwd", type: optStr },
4007
4028
  { name: "encoding", type: STRING },
4029
+ { name: "env", type: env },
4008
4030
  { name: "input", type: optStr },
4009
4031
  { name: "shell", type: optBool },
4010
4032
  { name: "stdio", type: stdio },
4011
4033
  { name: "timeout", type: optNum },
4012
4034
  { name: "windowsHide", type: optBool },
4013
- ], false, undefined, ["encoding", "cwd", "input", "timeout", "shell", "stdio", "windowsHide"]),
4035
+ ], false, undefined, ["encoding", "cwd", "env", "input", "timeout", "shell", "stdio", "windowsHide"]),
4014
4036
  };
4015
4037
  }
4016
4038
  if (isStdlibInterface("AddressInfo")) {
@@ -4212,7 +4234,7 @@ function mapTypeInner(type, ctx) {
4212
4234
  if (!t || t.kind !== "string")
4213
4235
  return null;
4214
4236
  }
4215
- const shellArms = [NULL_T, STRING].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
4237
+ const shellArms = sortArms([NULL_T, STRING]);
4216
4238
  const shell = { kind: "union", unionId: ctx.unions.intern(shellArms) };
4217
4239
  return {
4218
4240
  kind: "record",
@@ -4463,7 +4485,7 @@ function mapTypeInner(type, ctx) {
4463
4485
  if (isStdlibInterface("NetworkInterfaceInfoIPv4") ||
4464
4486
  isStdlibInterface("NetworkInterfaceInfoIPv6")) {
4465
4487
  const v6 = ts.symbolName(psym) === "NetworkInterfaceInfoIPv6";
4466
- const cidrArms = [NULL_T, STRING].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
4488
+ const cidrArms = sortArms([NULL_T, STRING]);
4467
4489
  const cidr = { kind: "union", unionId: ctx.unions.intern(cidrArms) };
4468
4490
  const scopeid = v6 ? F64 : withUndefinedArm(F64, ctx.unions);
4469
4491
  if (!scopeid)
@@ -4544,9 +4566,18 @@ function mapTypeInner(type, ctx) {
4544
4566
  // the plain-func mapping below (historic behavior: the properties drop
4545
4567
  // from the type).
4546
4568
  if (widened.isIntersectionType() && checker.getConstructSignatures(widened).length === 0) {
4547
- const hybrid = mapHybridCallableIntersection(widened, ctx);
4548
- if (hybrid)
4549
- return hybrid;
4569
+ // node:test's `Mock<F>` (`F & { mock: MockFunctionContext<F> }`) keeps
4570
+ // its hybrid `%call` record: the `mock` member is the runner's live
4571
+ // call log, which the mock lowering builds and mutates, not data the
4572
+ // closure's own-property table could carry yet.
4573
+ if (isMockHybridIntersection(widened, ctx)) {
4574
+ const hybrid = mapHybridCallableRecord(widened, ctx);
4575
+ if (hybrid)
4576
+ return hybrid;
4577
+ }
4578
+ const callable = mapCallableIntersection(widened, ctx);
4579
+ if (callable)
4580
+ return callable;
4550
4581
  // Recursive and Symbol-keyed callable objects need their complete live
4551
4582
  // property table; dropping those members into a plain closure loses data.
4552
4583
  if (checker.getCallSignatures(widened).length > 0 &&
@@ -4600,6 +4631,30 @@ function mapTypeInner(type, ctx) {
4600
4631
  if (erased !== undefined)
4601
4632
  return erased;
4602
4633
  }
4634
+ // An overload set whose signatures are the SAME once union members are
4635
+ // read as a set is one signature: `typeof fetch` merges lib.dom's
4636
+ // `(input: URL | RequestInfo, ...)` with undici's `(input: string |
4637
+ // Request | URL, ...)`, which spell the same members in a different
4638
+ // order. Union interning keeps arm order, so the two mapped signatures
4639
+ // differ by unionId alone; a set whose signatures genuinely differ (a
4640
+ // rest parameter elsewhere, another result type) keeps its fence.
4641
+ // Erasable sets (isOverloadedCallableMemberType) already have their one
4642
+ // compiled signature and keep it: this arm is for the sets no erasure
4643
+ // reaches, such as a merged library declaration.
4644
+ // The signatures are mapped LAZILY, and only while the set is not already
4645
+ // being mapped higher up the stack: mapping a signature maps its parameter
4646
+ // and return types, so a recursive result type (`interface R { (x: number):
4647
+ // R; (x: string): R }` in a package declaration) re-enters the set and
4648
+ // would otherwise map every signature again at every level — exponential
4649
+ // until MAP_TYPE_MAX_DEPTH cuts each branch, stalling the build instead of
4650
+ // reporting the refusal (see overloadSetBeingExpanded).
4651
+ if (callSigs.length > 1 &&
4652
+ !isOverloadedCallableMemberType(widened, checker) &&
4653
+ !overloadSetBeingExpanded(widened)) {
4654
+ const agreed = mapAgreeingOverloadSignature(callSigs, widened, ctx);
4655
+ if (agreed !== null)
4656
+ return agreed;
4657
+ }
4603
4658
  if (callSigs.length === 1)
4604
4659
  return mapCallSignature(callSigs[0], ctx);
4605
4660
  // Records: object types whose members are all data properties (shorthand
@@ -5008,7 +5063,7 @@ function mapTypeInner(type, ctx) {
5008
5063
  !maybePromiseUnionOk(parts, mergedArms, ctx)) {
5009
5064
  return null;
5010
5065
  }
5011
- mergedArms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
5066
+ sortArms(mergedArms);
5012
5067
  const discriminant = unionDiscriminant(recordParts, mergedArms, ctx) ??
5013
5068
  (substitutedUnions.length === 1
5014
5069
  ? remapUnionDiscriminant(substitutedUnions[0], mergedArms)
@@ -5107,6 +5162,89 @@ function isStdlibStreamWriteOverloads(sigs, ctx) {
5107
5162
  ctx.isStdlibFile(ts.getSourceFileOfNode(decl)));
5108
5163
  });
5109
5164
  }
5165
+ /** An overloaded set's identity for the expansion guard. A generic set
5166
+ * re-enters under a FRESH type object at each level (`interface R<T> { (x:
5167
+ * T): R<T[]> }`), so the declaration a type instantiation names stands in for
5168
+ * the type; an anonymous type literal is interned by the checker, so the type
5169
+ * itself is its own identity. */
5170
+ function overloadSetKey(type) {
5171
+ return type.getAliasSymbol() ?? type.getSymbol() ?? type;
5172
+ }
5173
+ /** True when `type` is already being expanded, or a chain of sets is
5174
+ * expanding that led back to it: mapping the set again can only repeat the
5175
+ * mapping that is already in progress, so the set has no single compiled
5176
+ * signature (see overloadExpansion). */
5177
+ function overloadSetBeingExpanded(type) {
5178
+ return overloadExpansion.includes(overloadSetKey(type));
5179
+ }
5180
+ /** The one signature `sigs` agree on, or null when they disagree or any of
5181
+ * them does not map. Signatures are mapped lazily — a set whose first two
5182
+ * signatures disagree costs two mappings — and the set stays on the expansion
5183
+ * stack throughout, so a signature naming the set again refuses it. */
5184
+ function mapAgreeingOverloadSignature(sigs, set, ctx) {
5185
+ overloadExpansion.push(overloadSetKey(set));
5186
+ try {
5187
+ const first = mapCallSignature(sigs[0], ctx);
5188
+ if (first === null)
5189
+ return null;
5190
+ for (let i = 1; i < sigs.length; i++) {
5191
+ const next = mapCallSignature(sigs[i], ctx);
5192
+ if (next === null || !sameTypeUpToUnionOrder(first, next, ctx, 0))
5193
+ return null;
5194
+ }
5195
+ return first;
5196
+ }
5197
+ finally {
5198
+ overloadExpansion.pop();
5199
+ }
5200
+ }
5201
+ /** Two mapped types that agree once every union's arms are read as a SET.
5202
+ * `URL | RequestInfo` and `string | Request | URL` name the same members
5203
+ * but intern as different unions (arm order is part of a union's identity),
5204
+ * so the overload dedupe below cannot use typeKey or typeEquals. Records and
5205
+ * handles compare by identity; the composite forms recurse. */
5206
+ function sameTypeUpToUnionOrder(a, b, ctx, depth) {
5207
+ if (typeKey(a) === typeKey(b))
5208
+ return true;
5209
+ if (depth > 16)
5210
+ return false;
5211
+ if (a.kind === "union" && b.kind === "union") {
5212
+ const armsA = ctx.unions.get(a.unionId)?.arms ?? [];
5213
+ const armsB = ctx.unions.get(b.unionId)?.arms ?? [];
5214
+ if (armsA.length !== armsB.length)
5215
+ return false;
5216
+ const rest = [...armsB];
5217
+ for (const arm of armsA) {
5218
+ const at = rest.findIndex((candidate) => sameTypeUpToUnionOrder(arm, candidate, ctx, depth + 1));
5219
+ if (at < 0)
5220
+ return false;
5221
+ rest.splice(at, 1);
5222
+ }
5223
+ return true;
5224
+ }
5225
+ switch (a.kind) {
5226
+ case "array":
5227
+ return b.kind === "array" && sameTypeUpToUnionOrder(a.elem, b.elem, ctx, depth + 1);
5228
+ case "promise":
5229
+ return b.kind === "promise" && sameTypeUpToUnionOrder(a.inner, b.inner, ctx, depth + 1);
5230
+ case "map":
5231
+ return (b.kind === "map" &&
5232
+ sameTypeUpToUnionOrder(a.key, b.key, ctx, depth + 1) &&
5233
+ sameTypeUpToUnionOrder(a.value, b.value, ctx, depth + 1));
5234
+ case "set":
5235
+ return b.kind === "set" && sameTypeUpToUnionOrder(a.elem, b.elem, ctx, depth + 1);
5236
+ case "func":
5237
+ return (b.kind === "func" &&
5238
+ a.params.length === b.params.length &&
5239
+ (a.rest ?? false) === (b.rest ?? false) &&
5240
+ (a.restAbi ?? null) === (b.restAbi ?? null) &&
5241
+ (a.argumentsAll ?? false) === (b.argumentsAll ?? false) &&
5242
+ a.params.every((p, i) => sameTypeUpToUnionOrder(p, b.params[i], ctx, depth + 1)) &&
5243
+ sameTypeUpToUnionOrder(a.ret, b.ret, ctx, depth + 1));
5244
+ default:
5245
+ return false;
5246
+ }
5247
+ }
5110
5248
  function mapCallSignature(sig, ctx) {
5111
5249
  const { checker } = ctx;
5112
5250
  if (sig.getTypeParameters().length && ctx.erasingSignature !== sig)
@@ -5158,27 +5296,36 @@ function mapCallSignature(sig, ctx) {
5158
5296
  let pt = mapType(checker.getTypeOfSymbol(p), ctx);
5159
5297
  // A parameter a TypeScript program types `any` takes whatever the
5160
5298
  // caller passes: the checked-dynamic slot, as an `any`-typed binding
5161
- // already is (dynFallbackType). Declaration files keep their paths.
5162
- // Only function declarations, spelled function types, method and call
5299
+ // already is (dynFallbackType). This holds in every declaration world
5300
+ // the program or a package writes — program source and `.d.ts`
5301
+ // declaration files alike, since a published declaration is the same
5302
+ // contract as the implementation source. The standard library keeps
5303
+ // its existing paths: its ambient signatures are the language's own
5304
+ // surface, so admitting them would change the static shape of every
5305
+ // typed program that calls one (`PropertyDescriptor.get`'s `this: any`,
5306
+ // `map`'s `thisArg?: any`), which the zero-cost gate forbids. Only
5307
+ // function declarations, spelled function types, method and call
5163
5308
  // signatures of interfaces and type literals (`execute(params: any):
5164
- // Promise<R>`), and lambda parameters whose default is the only source
5165
- // of their type (`(n = lookup() ?? 5) => ...` with an `any` lookup):
5166
- // other lambdas and methods in object literals keep their existing
5167
- // checked-dynamic story.
5309
+ // Promise<R>`), ambient class methods, and lambda parameters whose
5310
+ // default is the only source of their type (`(n = lookup() ?? 5) =>
5311
+ // ...` with an `any` lookup): other lambdas and methods in object
5312
+ // literals keep their existing checked-dynamic story.
5168
5313
  if (!pt &&
5169
5314
  !rest &&
5170
5315
  decl !== undefined &&
5171
5316
  ts.isParameter(decl) &&
5172
5317
  decl.parent !== undefined &&
5318
+ !(ts.getSourceFileOfNode(decl).isDeclarationFile &&
5319
+ ctx.isStdlibFile(ts.getSourceFileOfNode(decl))) &&
5173
5320
  (ts.isFunctionDeclaration(decl.parent) ||
5174
5321
  ts.isFunctionTypeNode(decl.parent) ||
5175
5322
  ts.isMethodSignatureDeclaration(decl.parent) ||
5176
5323
  ts.isCallSignatureDeclaration(decl.parent) ||
5324
+ (ts.isMethodDeclaration(decl.parent) && ts.getSourceFileOfNode(decl).isDeclarationFile) ||
5177
5325
  ((ts.isArrowFunction(decl.parent) || ts.isFunctionExpression(decl.parent)) &&
5178
5326
  decl.initializer !== undefined &&
5179
5327
  decl.type === undefined &&
5180
5328
  !isJsSourceFile(ts.getSourceFileOfNode(decl)))) &&
5181
- !ts.getSourceFileOfNode(decl).isDeclarationFile &&
5182
5329
  (checker.getTypeOfSymbol(p).flags & ts.TypeFlags.Any) !== 0)
5183
5330
  pt = DYN;
5184
5331
  if (decl &&
@@ -6047,7 +6194,7 @@ function mapGenericIndexedAccess(type, ctx) {
6047
6194
  }
6048
6195
  if (arms.length === 1)
6049
6196
  return arms[0];
6050
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6197
+ sortArms(arms);
6051
6198
  return { kind: "union", unionId: ctx.unions.intern(arms) };
6052
6199
  }
6053
6200
  /** A distributive conditional (`T extends "a" ? A : T extends "b" ? B :
@@ -6162,7 +6309,7 @@ function mapDistributedConditional(type, ctx) {
6162
6309
  return arms[0];
6163
6310
  if (!unionContainerArmsOk(arms))
6164
6311
  return null;
6165
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6312
+ sortArms(arms);
6166
6313
  return { kind: "union", unionId: ctx.unions.intern(arms) };
6167
6314
  }
6168
6315
  /** `keyof T extends never ? A : B` over a bound record T (the lib's
@@ -6241,13 +6388,18 @@ function mapBoundMappedType(widened, ctx) {
6241
6388
  const optional = modifier === ts.SyntaxKind.MinusToken
6242
6389
  ? false
6243
6390
  : modifier !== undefined || (property.flags & ts.SymbolFlags.Optional) !== 0;
6391
+ let absentable = false;
6244
6392
  if (optional) {
6245
- const armed = withUndefinedArm(type, unions);
6246
- if (!armed)
6247
- return null;
6248
- type = armed;
6393
+ if (type.kind === "dyn")
6394
+ absentable = true;
6395
+ else {
6396
+ const armed = withUndefinedArm(type, unions);
6397
+ if (!armed)
6398
+ return null;
6399
+ type = armed;
6400
+ }
6249
6401
  }
6250
- fields.push({ name, type });
6402
+ fields.push({ name, type, ...(absentable ? { optional: true } : {}) });
6251
6403
  order.push(name);
6252
6404
  }
6253
6405
  fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
@@ -6588,6 +6740,12 @@ function mapGenericUtilityAlias(widened, ctx) {
6588
6740
  return null;
6589
6741
  const fields = [];
6590
6742
  for (const f of shape.fields) {
6743
+ // Partial makes every property optional: a checked-dynamic slot becomes
6744
+ // absentable, every other one gains the undefined arm.
6745
+ if (f.type.kind === "dyn") {
6746
+ fields.push({ name: f.name, type: f.type, optional: true });
6747
+ continue;
6748
+ }
6591
6749
  const armed = withUndefinedArm(f.type, unions);
6592
6750
  if (!armed)
6593
6751
  return null;
@@ -6615,7 +6773,7 @@ function mapGenericUtilityAlias(widened, ctx) {
6615
6773
  * that could inhabit the extra arm. */
6616
6774
  export function unitOnlyUnion(unions) {
6617
6775
  const arms = [NULL_T, UNDEFINED_T];
6618
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6776
+ sortArms(arms);
6619
6777
  return { kind: "union", unionId: unions.intern(arms) };
6620
6778
  }
6621
6779
  /** `Iterable<T>`: a union whose arms are the sources that keep their own
@@ -6649,7 +6807,7 @@ export function iterableUnionType(elem, shapes, unions) {
6649
6807
  isSupportedMapValue(v.type))
6650
6808
  arms.push({ kind: "map", key: k.type, value: v.type });
6651
6809
  }
6652
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6810
+ sortArms(arms);
6653
6811
  return { kind: "union", unionId: unions.intern(arms) };
6654
6812
  }
6655
6813
  /** The IteratorResult record of a generator's value channels: `{ done:
@@ -6699,7 +6857,7 @@ export function genResultRecord(yieldT, retT, shapes, unions) {
6699
6857
  valueT = unitOnlyUnion(unions);
6700
6858
  }
6701
6859
  else {
6702
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6860
+ sortArms(arms);
6703
6861
  valueT = { kind: "union", unionId: unions.intern(arms) };
6704
6862
  }
6705
6863
  }
@@ -6775,6 +6933,13 @@ export const X509_FIELDS = [
6775
6933
  export function withUndefinedArm(t, unions) {
6776
6934
  return withUnitArm(t, "undefinedT", unions);
6777
6935
  }
6936
+ /** A record property declared `?:` whose mapped type is the checked-dynamic
6937
+ * slot. Only such a field's shape carries an ABSENT state of its own (the
6938
+ * absent marker); every other optional property maps to an undefined-armed
6939
+ * union, whose absence is the union's ABSENT state. */
6940
+ function optionalCheckedDyn(p, type) {
6941
+ return type.kind === "dyn" && (p.flags & ts.SymbolFlags.Optional) !== 0;
6942
+ }
6778
6943
  /** Preserve a nullish runtime value that JavaScript inference omitted. */
6779
6944
  export function withUnitArm(t, kind, unions) {
6780
6945
  const unit = { kind };
@@ -6788,7 +6953,7 @@ export function withUnitArm(t, kind, unions) {
6788
6953
  // Date and Promise arms beside other data arms have no union home.
6789
6954
  if (!unionContainerArmsOk(arms))
6790
6955
  return null;
6791
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6956
+ sortArms(arms);
6792
6957
  return { kind: "union", unionId: unions.transform(def, arms) };
6793
6958
  }
6794
6959
  if (t.kind === "void" ||
@@ -6799,7 +6964,7 @@ export function withUnitArm(t, kind, unions) {
6799
6964
  return null;
6800
6965
  }
6801
6966
  const arms = [t, unit];
6802
- arms.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
6967
+ sortArms(arms);
6803
6968
  return { kind: "union", unionId: unions.intern(arms) };
6804
6969
  }
6805
6970
  /** The chalk-shape recognizer behind mapType's hybrid branch: an
@@ -6878,7 +7043,68 @@ function mapClassExpandoIntersection(widened, ctx) {
6878
7043
  }
6879
7044
  return DYN;
6880
7045
  }
6881
- function mapHybridCallableIntersection(widened, ctx) {
7046
+ /** `F & { data }` maps to the CALLABLE part's func type: the members live in
7047
+ * the closure's own-property table (lowering/callable-properties.ts), so the
7048
+ * value IS the function — identity, aliasing, `typeof`, enumeration and
7049
+ * inspect all answer as Node's function object does. The parts that cannot
7050
+ * share that one representation (a recursive or `this`-typed member, a
7051
+ * symbol-keyed member, an accessor, a class or index-signature part) return
7052
+ * null, and the caller keeps the DYN mapping. */
7053
+ function mapCallableIntersection(widened, ctx) {
7054
+ const { checker } = ctx;
7055
+ if (!widened.isIntersectionType())
7056
+ return null;
7057
+ if (checker.getCallSignatures(widened).length !== 1)
7058
+ return null;
7059
+ let funcPart = null;
7060
+ for (const part of ts.constituentTypes(widened)) {
7061
+ if (checker.getCallSignatures(part).length > 0) {
7062
+ if (funcPart)
7063
+ return null; // exactly one callable part
7064
+ funcPart = part;
7065
+ continue;
7066
+ }
7067
+ const partSym = part.getSymbol();
7068
+ if ((part.flags & ts.TypeFlags.Object) === 0 ||
7069
+ checker.getConstructSignatures(part).length > 0 ||
7070
+ (partSym !== undefined && (partSym.flags & ts.SymbolFlags.Class) !== 0) ||
7071
+ checker.getIndexInfosOfType(part).length > 0) {
7072
+ return null;
7073
+ }
7074
+ }
7075
+ if (!funcPart)
7076
+ return null;
7077
+ const properties = checker.getPropertiesOfType(widened);
7078
+ if (properties.length === 0)
7079
+ return null; // no properties — it is just F
7080
+ for (const p of properties) {
7081
+ if (p.flags & (ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor))
7082
+ return null;
7083
+ // A symbol-keyed member has no string key in the table.
7084
+ if (ts.symbolName(p).startsWith("__@"))
7085
+ return null;
7086
+ }
7087
+ const fn = mapType(funcPart, ctx);
7088
+ return fn?.kind === "func" ? fn : null;
7089
+ }
7090
+ /** Whether `widened` is node:test's `Mock<F>` — an intersection carrying a
7091
+ * `mock: MockFunctionContext<F>` member declared in the ambient `test`
7092
+ * module (the same provenance check MockFunctionContext's own mapping
7093
+ * uses). */
7094
+ function isMockHybridIntersection(widened, ctx) {
7095
+ if (!widened.isIntersectionType())
7096
+ return false;
7097
+ const mock = ctx.checker.getPropertyOfType(widened, "mock");
7098
+ if (mock === undefined)
7099
+ return false;
7100
+ const sym = ctx.checker.getTypeOfSymbol(mock).getSymbol();
7101
+ return (sym !== undefined &&
7102
+ ts.symbolName(sym) === "MockFunctionContext" &&
7103
+ sym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
7104
+ ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
7105
+ isDeclaredInAmbientModule(d, "test")));
7106
+ }
7107
+ function mapHybridCallableRecord(widened, ctx) {
6882
7108
  const { checker, shapes } = ctx;
6883
7109
  if (!widened.isIntersectionType())
6884
7110
  return null;
@@ -6913,7 +7139,11 @@ function mapHybridCallableIntersection(widened, ctx) {
6913
7139
  const pt = mapType(checker.getTypeOfSymbol(p), ctx);
6914
7140
  if (!pt || pt.kind === "void")
6915
7141
  return null;
6916
- fields.push({ name: ts.symbolName(p), type: pt });
7142
+ fields.push({
7143
+ name: ts.symbolName(p),
7144
+ type: pt,
7145
+ ...(optionalCheckedDyn(p, pt) ? { optional: true } : {}),
7146
+ });
6917
7147
  declaredOrder.push(ts.symbolName(p));
6918
7148
  }
6919
7149
  if (fields.length === 1)
@@ -6921,8 +7151,12 @@ function mapHybridCallableIntersection(widened, ctx) {
6921
7151
  fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
6922
7152
  return { kind: "record", shapeId: shapes.intern(fields, false, undefined, declaredOrder) };
6923
7153
  }
6924
- /** The record every part of a union of function-with-properties
6925
- * intersections maps to, or null when a part does not map to the same one. */
7154
+ /** The representation every part of a union of function-with-properties
7155
+ * intersections maps to, or null when a part does not map to the same one.
7156
+ * Each part maps exactly as it does alone — an ordinary callable
7157
+ * intersection to the callable's func type (its members ARE the closure's
7158
+ * own properties), node:test's `Mock<F>` to its hybrid `%call` record — so a
7159
+ * union never reintroduces the record a value no longer has. */
6926
7160
  function mapUniformHybridUnion(widened, ctx) {
6927
7161
  const parts = ts.constituentTypes(widened);
6928
7162
  if (!parts.every((p) => p.isIntersectionType()))
@@ -6931,7 +7165,9 @@ function mapUniformHybridUnion(widened, ctx) {
6931
7165
  for (const part of parts) {
6932
7166
  if (ctx.checker.getConstructSignatures(part).length > 0)
6933
7167
  return null;
6934
- const mapped = mapHybridCallableIntersection(part, ctx);
7168
+ const mapped = isMockHybridIntersection(part, ctx)
7169
+ ? mapHybridCallableRecord(part, ctx)
7170
+ : mapCallableIntersection(part, ctx);
6935
7171
  if (!mapped || (first && typeKey(mapped) !== typeKey(first)))
6936
7172
  return null;
6937
7173
  first ??= mapped;
@@ -7021,9 +7257,10 @@ function mapErrorMetadataIntersection(type, ctx) {
7021
7257
  /** A conventional primitive brand has one runtime-carrying primitive part
7022
7258
  * and one or more phantom object parts whose fields are literal marker
7023
7259
  * values. The marker can use a string or unique-symbol key, can be imported
7024
- * from a declaration file, and can be expressed through a generic alias;
7025
- * none of those facts changes the runtime value. Empty `{}` refinements are
7026
- * the marker-free form of the same primitive narrowing.
7260
+ * from a declaration file, can be expressed through a generic alias, and can
7261
+ * nest tables of further markers; none of those facts changes the runtime
7262
+ * value. Empty `{}` refinements are the marker-free form of the same
7263
+ * primitive narrowing.
7027
7264
  *
7028
7265
  * Arbitrary primitive/object intersections do not erase here. A companion
7029
7266
  * with a class identity, call/construct/index signature, accessor, or a
@@ -7059,7 +7296,7 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
7059
7296
  }
7060
7297
  return null;
7061
7298
  };
7062
- const markerValue = (value) => {
7299
+ const markerValue = (value, seen = new Set()) => {
7063
7300
  if (value.flags &
7064
7301
  (ts.TypeFlags.StringLiteral |
7065
7302
  ts.TypeFlags.NumberLiteral |
@@ -7074,15 +7311,42 @@ function mapBrandedPrimitiveIntersection(widened, ctx) {
7074
7311
  return true;
7075
7312
  }
7076
7313
  if (value.isUnionType())
7077
- return ts.constituentTypes(value).every(markerValue);
7314
+ return ts.constituentTypes(value).every((part) => markerValue(part, seen));
7078
7315
  if (value.flags & ts.TypeFlags.TypeParameter) {
7079
7316
  const bound = resolveTypeParamTs?.(value) ?? null;
7080
7317
  if (bound) {
7081
7318
  contextResolutions++;
7082
- return markerValue(bound);
7319
+ return markerValue(bound, seen);
7083
7320
  }
7084
7321
  }
7085
- return false;
7322
+ // A NESTED marker table (`{ readonly ["~effect/Brand"]: { readonly
7323
+ // ProviderDriverKind: "ProviderDriverKind" } }`): an object whose own
7324
+ // members are all markers describes no runtime data, so the nesting
7325
+ // does not make the marker observable. Class identity, call, construct
7326
+ // or index signatures, accessors, and non-literal value fields stay
7327
+ // outside the rule, because those can describe runtime behavior.
7328
+ if ((value.flags & ts.TypeFlags.Object) === 0)
7329
+ return false;
7330
+ if (seen.has(value))
7331
+ return false;
7332
+ seen.add(value);
7333
+ // `seen` holds the types on the current path only: two sibling fields
7334
+ // that name the same marker type both erase, while a table that refers
7335
+ // to itself stays outside the rule.
7336
+ let marker = false;
7337
+ const sym = value.getSymbol();
7338
+ if (sym === undefined || (sym.flags & ts.SymbolFlags.Class) === 0) {
7339
+ marker =
7340
+ checker.getCallSignatures(value).length === 0 &&
7341
+ checker.getConstructSignatures(value).length === 0 &&
7342
+ checker.getIndexInfosOfType(value).length === 0 &&
7343
+ checker
7344
+ .getPropertiesOfType(value)
7345
+ .every((prop) => (prop.flags & (ts.SymbolFlags.GetAccessor | ts.SymbolFlags.SetAccessor)) === 0 &&
7346
+ markerValue(checker.getTypeOfSymbol(prop), seen));
7347
+ }
7348
+ seen.delete(value);
7349
+ return marker;
7086
7350
  };
7087
7351
  let primitive = null;
7088
7352
  let markerParts = 0;
@@ -7301,7 +7565,14 @@ export function packageTypeIsData(type, ctx) {
7301
7565
  if (!data)
7302
7566
  return false;
7303
7567
  }
7304
- return declared;
7568
+ if (declared)
7569
+ return true;
7570
+ // A union spelled through a package type alias whose members all come
7571
+ // from elsewhere (`type RawData = Buffer | ArrayBuffer | Buffer[]`):
7572
+ // no member carries the package's provenance, but the alias declaration
7573
+ // is the package's data shape, so the type is still data the program
7574
+ // builds and never a value the package's implementation produces.
7575
+ return packageDataPart(type, ctx) === true;
7305
7576
  }
7306
7577
  /** The record path's provenance fence. Declared shapes (object literals,
7307
7578
  * interfaces, type literals) must come from user code or an explicitly
@@ -7517,7 +7788,7 @@ function joinOverloadTypes(types, ctx) {
7517
7788
  }
7518
7789
  }
7519
7790
  if (scalar && [...arms.values()].some((arm) => !isUnitType(arm))) {
7520
- const sorted = [...arms.values()].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
7791
+ const sorted = sortArms([...arms.values()]);
7521
7792
  return { kind: "union", unionId: ctx.unions.intern(sorted) };
7522
7793
  }
7523
7794
  if (types.every((t) => t.kind === "dyn" ||
@@ -7578,8 +7849,12 @@ export function erasedOverloadMemberType(t, ctx) {
7578
7849
  /** Why an overloaded member's set has no erased type
7579
7850
  * (erasedOverloadMemberType): the first overload, and within it the first
7580
7851
  * parameter or result, that does not map; otherwise the join itself. A
7581
- * message tail after "its member 'name'". */
7582
- function describeOverloadSetBlocker(t, ctx) {
7852
+ * message tail after "its member 'name'". `depth` and `seen` continue the
7853
+ * enclosing description's walk: an overload whose parameter or result
7854
+ * names the record being described (`interface Chain { attach(next:
7855
+ * Chain): Chain }`) must answer from that walk, not restart it, or each
7856
+ * overload tail would describe the same set again without end. */
7857
+ function describeOverloadSetBlocker(t, ctx, depth, seen) {
7583
7858
  const { checker } = ctx;
7584
7859
  for (const sig of checker.getCallSignatures(t)) {
7585
7860
  const own = new Set(sig.getTypeParameters());
@@ -7602,10 +7877,10 @@ function describeOverloadSetBlocker(t, ctx) {
7602
7877
  for (const param of sig.getParameters()) {
7603
7878
  const paramTs = checker.getTypeOfSymbol(param);
7604
7879
  if (!mapType(paramTs, sigCtx))
7605
- return `is an overload set, and its ${which} has parameter '${ts.symbolName(param)}' of type '${checker.typeToString(paramTs)}', which does not compile`;
7880
+ return `is an overload set, and its ${which} has parameter '${ts.symbolName(param)}' of type '${checker.typeToString(paramTs)}', which does not compile${slotReason(paramTs, ctx, depth + 1, seen)}`;
7606
7881
  }
7607
7882
  const retTs = checker.getReturnTypeOfSignature(sig);
7608
- return `is an overload set, and its ${which} returns '${checker.typeToString(retTs)}', which does not compile`;
7883
+ return `is an overload set, and its ${which} returns '${checker.typeToString(retTs)}', which does not compile${slotReason(retTs, ctx, depth + 1, seen)}`;
7609
7884
  }
7610
7885
  return "is an overload set whose signatures do not join into one stored function (a void result beside a value result, or positions whose differing types do not cross the checked-dynamic boundary)";
7611
7886
  }
@@ -7875,7 +8150,7 @@ function dictSpreadLiteralShape(widened, parts, ctx) {
7875
8150
  return null;
7876
8151
  if (![...arms.values()].some((arm) => !isUnitType(arm)))
7877
8152
  return null;
7878
- const sorted = [...arms.values()].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
8153
+ const sorted = sortArms([...arms.values()]);
7879
8154
  const slot = sorted.length === 1 ? sorted[0] : { kind: "union", unionId: unions.intern(sorted) };
7880
8155
  return shapes.intern([], false, slot, []);
7881
8156
  }
@@ -8137,7 +8412,7 @@ function mapRecordTypeInner(widened, ctx) {
8137
8412
  slotDef.arms.some((a) => a.kind === "array" && a.elem.kind === "string") &&
8138
8413
  slotDef.arms.every(armOk)) {
8139
8414
  const armsRaw = [F64, STRING, arrayOf(STRING), UNDEFINED_T];
8140
- armsRaw.sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1));
8415
+ sortArms(armsRaw);
8141
8416
  const canonical = { kind: "union", unionId: ctx.unions.intern(armsRaw) };
8142
8417
  const fits = (t) => {
8143
8418
  if (!t)
@@ -8370,7 +8645,11 @@ function mapRecordTypeInner(widened, ctx) {
8370
8645
  if (accessorSlotProp(ts.symbolName(p)) !== null)
8371
8646
  return null;
8372
8647
  // an options record with `signal?: AbortSignal` must not turn its
8373
- fields.push({ name: ts.symbolName(p), type: pt });
8648
+ fields.push({
8649
+ name: ts.symbolName(p),
8650
+ type: pt,
8651
+ ...(optionalCheckedDyn(p, pt) ? { optional: true } : {}),
8652
+ });
8374
8653
  }
8375
8654
  // getPropertiesOfType yields DECLARATION order (interface/alias/literal
8376
8655
  // source order) — captured before the canonical sort so Object.keys/
@@ -8582,7 +8861,7 @@ function mergePromiseArms(arms, ctx) {
8582
8861
  : payload.every((arm) => armHasUnionHome(arm))
8583
8862
  ? {
8584
8863
  kind: "union",
8585
- unionId: ctx.unions.intern([...payload].sort((a, b) => (typeKey(a) < typeKey(b) ? -1 : 1))),
8864
+ unionId: ctx.unions.intern(sortArms([...payload])),
8586
8865
  }
8587
8866
  : null;
8588
8867
  const merged = inner === null ? null : { kind: "promise", inner };
@@ -8618,14 +8897,37 @@ function armHasUnionHome(arm) {
8618
8897
  return true;
8619
8898
  }
8620
8899
  }
8900
+ /** The deeper story of why an ABI slot (a container argument, union arm,
8901
+ * array/tuple element, function parameter or return type) does not compile,
8902
+ * as a tail for its "... does not compile" sentence: the record member or
8903
+ * nested component actually at fault. Empty when the slot's own type is the
8904
+ * blocker, which keeps the flat message. Naming the member matters for the
8905
+ * shapes a real program passes around — a 33-member `ExtensionAPI` is not a
8906
+ * useful answer. `depth` bounds the recursion over self-referential shapes
8907
+ * (`type F = (f: F) => void`); `innerBlockedMember`'s own `seen` set cannot
8908
+ * see across the describeComponentBlocker call. */
8909
+ function slotReason(t, ctx, depth, seen = new Set()) {
8910
+ // A self-referential shape (`type F = () => F`) reaches the same type
8911
+ // again at every step: saying the same sentence twice adds nothing.
8912
+ if (depth >= 3 || seen.has(t))
8913
+ return "";
8914
+ seen.add(t);
8915
+ const why = describeRecordMemberBlocker(t, ctx, depth, seen) ??
8916
+ describeComponentBlocker(t, ctx, depth + 1, seen);
8917
+ return why === null ? "" : `: ${why}`;
8918
+ }
8621
8919
  /** When an unmapped type is a SUPPORTED container/composite whose failure
8622
8920
  * lives in a component, answer a message tail naming the component (the
8623
8921
  * SC2009 story); null when the shape itself is the blocker (the caller
8624
8922
  * falls through to the other fences). Stdlib container heads (Map, Set,
8625
8923
  * Promise, generators) ALWAYS answer — their shapes have lowerings, so a
8626
8924
  * later "no lowering" claim about them would be false. */
8627
- export function describeComponentBlocker(widened, ctx) {
8925
+ export function describeComponentBlocker(widened, ctx, depth = 0, inherited) {
8628
8926
  const { checker } = ctx;
8927
+ // The type under description is already spoken for: a component that
8928
+ // leads back to it (`type F = () => F`) has nothing to add.
8929
+ const seen = inherited ?? new Set();
8930
+ seen.add(widened);
8629
8931
  const text = (t) => checker.typeToString(t);
8630
8932
  // Stdlib container references (provenance, not the name — a user's own
8631
8933
  // `interface Map` is a record shape and keeps the record stories).
@@ -8643,7 +8945,7 @@ export function describeComponentBlocker(widened, ctx) {
8643
8945
  const role = spec.role(i);
8644
8946
  const mapped = mapType(arg, ctx);
8645
8947
  if (!mapped) {
8646
- return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile`;
8948
+ return `the ${container} shape is supported, but its ${role} type '${text(arg)}' does not compile${slotReason(arg, ctx, depth, seen)}`;
8647
8949
  }
8648
8950
  if ((container === "Map" || container === "ReadonlyMap") &&
8649
8951
  i === 0 &&
@@ -8673,7 +8975,7 @@ export function describeComponentBlocker(widened, ctx) {
8673
8975
  return null;
8674
8976
  const elem = mapType(elemTs, ctx);
8675
8977
  if (!elem) {
8676
- return `the array shape is supported, but its element type '${text(elemTs)}' does not compile`;
8978
+ return `the array shape is supported, but its element type '${text(elemTs)}' does not compile${slotReason(elemTs, ctx, depth, seen)}`;
8677
8979
  }
8678
8980
  return `the array shape is supported, but '${text(elemTs)}' elements have no array representation yet`;
8679
8981
  }
@@ -8686,7 +8988,7 @@ export function describeComponentBlocker(widened, ctx) {
8686
8988
  if (et?.kind === "void" && isUnitOnlyTsType(arg, ctx.resolveTypeParam))
8687
8989
  continue;
8688
8990
  if (!et || et.kind === "void") {
8689
- return `the tuple shape is supported, but its element type '${text(arg)}' does not compile`;
8991
+ return `the tuple shape is supported, but its element type '${text(arg)}' does not compile${slotReason(arg, ctx, depth, seen)}`;
8690
8992
  }
8691
8993
  }
8692
8994
  return null;
@@ -8716,7 +9018,7 @@ export function describeComponentBlocker(widened, ctx) {
8716
9018
  }
8717
9019
  for (const { p: part, mapped } of mappedArms) {
8718
9020
  if (!mapped) {
8719
- return `the union shape is supported, but its arm '${text(part)}' does not compile`;
9021
+ return `the union shape is supported, but its arm '${text(part)}' does not compile${slotReason(part, ctx, depth, seen)}`;
8720
9022
  }
8721
9023
  if (!armHasUnionHome(mapped)) {
8722
9024
  return `the union shape is supported, but '${text(part)}' arms have no home in a compiled union yet (no runtime narrowing test exists against sibling arms)`;
@@ -8758,12 +9060,12 @@ export function describeComponentBlocker(widened, ctx) {
8758
9060
  for (const p of sig.getParameters()) {
8759
9061
  const pTs = checker.getTypeOfSymbol(p);
8760
9062
  if (!mapType(pTs, ctx)) {
8761
- return `the function shape is supported, but its parameter '${ts.symbolName(p)}' has type '${text(pTs)}', which does not compile`;
9063
+ return `the function shape is supported, but its parameter '${ts.symbolName(p)}' has type '${text(pTs)}', which does not compile${slotReason(pTs, ctx, depth, seen)}`;
8762
9064
  }
8763
9065
  }
8764
9066
  const retTs = checker.getReturnTypeOfSignature(sig);
8765
9067
  if ((retTs.flags & ts.TypeFlags.Never) === 0 && !mapType(retTs, ctx)) {
8766
- return `the function shape is supported, but its return type '${text(retTs)}' does not compile`;
9068
+ return `the function shape is supported, but its return type '${text(retTs)}' does not compile${slotReason(retTs, ctx, depth, seen)}`;
8767
9069
  }
8768
9070
  return null;
8769
9071
  }
@@ -8774,8 +9076,10 @@ export function describeComponentBlocker(widened, ctx) {
8774
9076
  * signature routing, so what reaches it is a plain data shape; a null
8775
9077
  * answer (no member pinpointed — provenance fences, accessor rules, shape
8776
9078
  * knots) keeps the residual SC2001 story. */
8777
- export function describeRecordMemberBlocker(widened, ctx) {
9079
+ export function describeRecordMemberBlocker(widened, ctx, depth = 0, inherited) {
8778
9080
  const { checker } = ctx;
9081
+ const seen = inherited ?? new Set();
9082
+ seen.add(widened);
8779
9083
  if ((widened.flags & ts.TypeFlags.Object) === 0)
8780
9084
  return null;
8781
9085
  if (checker.getCallSignatures(widened).length > 0)
@@ -8811,7 +9115,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
8811
9115
  if (isOverloadedCallableMemberType(fieldTs, checker)) {
8812
9116
  if (erasedOverloadMemberType(fieldTs, ctx) !== undefined)
8813
9117
  continue;
8814
- return `the record shape is supported, but its member '${ts.symbolName(p)}' ${describeOverloadSetBlocker(fieldTs, ctx)}`;
9118
+ return `the record shape is supported, but its member '${ts.symbolName(p)}' ${describeOverloadSetBlocker(fieldTs, ctx, depth, seen)}`;
8815
9119
  }
8816
9120
  if (memberMaps(fieldTs, ctx, p))
8817
9121
  continue;
@@ -8820,7 +9124,7 @@ export function describeRecordMemberBlocker(widened, ctx) {
8820
9124
  // its outermost member.
8821
9125
  const inner = innerBlockedMember(fieldTs, ctx, new Set());
8822
9126
  if (inner !== null && inner.path !== "") {
8823
- return `the record shape is supported, but its member '${ts.symbolName(p)}${inner.path}' has type '${checker.typeToString(inner.type)}', which does not compile`;
9127
+ return `the record shape is supported, but its member '${ts.symbolName(p)}${inner.path}' has type '${checker.typeToString(inner.type)}', which does not compile${slotReason(inner.type, ctx, depth + 1, seen)}`;
8824
9128
  }
8825
9129
  return `the record shape is supported, but its member '${ts.symbolName(p)}' has type '${checker.typeToString(fieldTs)}', which does not compile`;
8826
9130
  }
@@ -8859,8 +9163,8 @@ function memberMaps(fieldTs, ctx, member) {
8859
9163
  }
8860
9164
  /** The member path inside the unmapped type `t` that its failure comes
8861
9165
  * from, and that member's type: `.name` steps into record members, `[]`
8862
- * into array elements, `()` into a function's return; union arms and
8863
- * promise payloads are transparent. The empty path means `t` itself is
9166
+ * into array elements, `(param)` into a function parameter, `()` into a
9167
+ * function's return; union arms and promise payloads are transparent. The empty path means `t` itself is
8864
9168
  * the blocker; null means `t` maps (or is `any`). */
8865
9169
  function innerBlockedMember(t, ctx, seen) {
8866
9170
  const { checker } = ctx;
@@ -8902,8 +9206,14 @@ function innerBlockedMember(t, ctx, seen) {
8902
9206
  const sig = calls[0];
8903
9207
  if (sig.getTypeParameters().length > 0)
8904
9208
  return here;
8905
- if (sig.getParameters().some((p) => mapType(checker.getTypeOfSymbol(p), ctx) === null))
8906
- return here;
9209
+ // A parameter carries the failure as often as the result does (an
9210
+ // event handler's `ctx`, a factory's `theme`): name that parameter's
9211
+ // slot instead of stopping at the function.
9212
+ for (const param of sig.getParameters()) {
9213
+ const paramTs = checker.getTypeOfSymbol(param);
9214
+ if (mapType(paramTs, ctx) === null)
9215
+ return step(`(${ts.symbolName(param)})`, paramTs);
9216
+ }
8907
9217
  return step("()", checker.getReturnTypeOfSignature(sig));
8908
9218
  }
8909
9219
  if (calls.length > 0 ||