@scriptc/compiler 0.4.7 → 0.4.8

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 (776) hide show
  1. package/ambient/node-fallback/child_process.d.ts +71 -22
  2. package/ambient/node-fallback/crypto.d.ts +15 -7
  3. package/ambient/node-fallback/events.d.ts +23 -5
  4. package/ambient/node-fallback/fs.d.ts +3 -2
  5. package/ambient/node-fallback/http.d.ts +23 -17
  6. package/ambient/node-fallback/https.d.ts +5 -2
  7. package/ambient/node-fallback/net.d.ts +6 -0
  8. package/ambient/node-fallback/os.d.ts +11 -1
  9. package/ambient/node-fallback/path-posix.d.ts +6 -0
  10. package/ambient/node-fallback/path-win32.d.ts +5 -0
  11. package/ambient/node-fallback/path.d.ts +2 -0
  12. package/ambient/node-fallback/zlib.d.ts +31 -2
  13. package/ambient/scriptc-node-fallback.d.ts +37 -7
  14. package/ambient/scriptc.d.ts +7 -2
  15. package/dist/backend/executable-features.js +11 -3
  16. package/dist/backend/executable-features.js.map +1 -1
  17. package/dist/backend/library-pack.d.ts +6 -0
  18. package/dist/backend/library-pack.js +17 -6
  19. package/dist/backend/library-pack.js.map +1 -1
  20. package/dist/backend/library-pack.test.d.ts +1 -0
  21. package/dist/backend/library-pack.test.js +28 -0
  22. package/dist/backend/library-pack.test.js.map +1 -0
  23. package/dist/backend/linker.d.ts +9 -2
  24. package/dist/backend/linker.js +190 -32
  25. package/dist/backend/linker.js.map +1 -1
  26. package/dist/backend/lld.d.ts +8 -4
  27. package/dist/backend/lld.js +19 -13
  28. package/dist/backend/lld.js.map +1 -1
  29. package/dist/backend/lld.test.js +3 -1
  30. package/dist/backend/lld.test.js.map +1 -1
  31. package/dist/backend/llvm/alloc.d.ts +15 -2
  32. package/dist/backend/llvm/alloc.js +172 -36
  33. package/dist/backend/llvm/alloc.js.map +1 -1
  34. package/dist/backend/llvm/alloc.test.js +69 -1
  35. package/dist/backend/llvm/alloc.test.js.map +1 -1
  36. package/dist/backend/llvm/arenas.d.ts +17 -4
  37. package/dist/backend/llvm/arenas.js +105 -10
  38. package/dist/backend/llvm/arenas.js.map +1 -1
  39. package/dist/backend/llvm/arenas.test.js +229 -0
  40. package/dist/backend/llvm/arenas.test.js.map +1 -1
  41. package/dist/backend/llvm/bytes-alias.js +10 -1
  42. package/dist/backend/llvm/bytes-alias.js.map +1 -1
  43. package/dist/backend/llvm/bytes-headers.js +6 -0
  44. package/dist/backend/llvm/bytes-headers.js.map +1 -1
  45. package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
  46. package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
  47. package/dist/backend/llvm/call-lifetimes.js +10 -0
  48. package/dist/backend/llvm/call-lifetimes.js.map +1 -1
  49. package/dist/backend/llvm/classes.d.ts +16 -9
  50. package/dist/backend/llvm/classes.js +142 -37
  51. package/dist/backend/llvm/classes.js.map +1 -1
  52. package/dist/backend/llvm/classes.test.js +42 -0
  53. package/dist/backend/llvm/classes.test.js.map +1 -1
  54. package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
  55. package/dist/backend/llvm/cpu-dispatch.js +31 -7
  56. package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
  57. package/dist/backend/llvm/dyn.d.ts +12 -3
  58. package/dist/backend/llvm/dyn.js +31 -7
  59. package/dist/backend/llvm/dyn.js.map +1 -1
  60. package/dist/backend/llvm/emit-function.js +67 -4
  61. package/dist/backend/llvm/emit-function.js.map +1 -1
  62. package/dist/backend/llvm/emit-module.js +90 -39
  63. package/dist/backend/llvm/emit-module.js.map +1 -1
  64. package/dist/backend/llvm/emit-module.test.d.ts +1 -0
  65. package/dist/backend/llvm/emit-module.test.js +52 -0
  66. package/dist/backend/llvm/emit-module.test.js.map +1 -0
  67. package/dist/backend/llvm/emit-statements.js +99 -15
  68. package/dist/backend/llvm/emit-statements.js.map +1 -1
  69. package/dist/backend/llvm/emitter.d.ts +113 -8
  70. package/dist/backend/llvm/emitter.js +438 -67
  71. package/dist/backend/llvm/emitter.js.map +1 -1
  72. package/dist/backend/llvm/emitter.test.js +31 -3
  73. package/dist/backend/llvm/emitter.test.js.map +1 -1
  74. package/dist/backend/llvm/expr-async.js +19 -1
  75. package/dist/backend/llvm/expr-async.js.map +1 -1
  76. package/dist/backend/llvm/expr-bytes.js +16 -1
  77. package/dist/backend/llvm/expr-bytes.js.map +1 -1
  78. package/dist/backend/llvm/expr-calls.js +18 -2
  79. package/dist/backend/llvm/expr-calls.js.map +1 -1
  80. package/dist/backend/llvm/expr-dynamic.js +31 -10
  81. package/dist/backend/llvm/expr-dynamic.js.map +1 -1
  82. package/dist/backend/llvm/expr-primitives.js +31 -3
  83. package/dist/backend/llvm/expr-primitives.js.map +1 -1
  84. package/dist/backend/llvm/expr-records.d.ts +1 -1
  85. package/dist/backend/llvm/expr-records.js +124 -56
  86. package/dist/backend/llvm/expr-records.js.map +1 -1
  87. package/dist/backend/llvm/expr-stream-bridges.js +17 -0
  88. package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
  89. package/dist/backend/llvm/js-groups.d.ts +21 -0
  90. package/dist/backend/llvm/js-groups.js +277 -0
  91. package/dist/backend/llvm/js-groups.js.map +1 -0
  92. package/dist/backend/llvm/js-ic.d.ts +19 -1
  93. package/dist/backend/llvm/js-ic.js +96 -23
  94. package/dist/backend/llvm/js-ic.js.map +1 -1
  95. package/dist/backend/llvm/lib-dispatch.js +132 -1
  96. package/dist/backend/llvm/lib-dispatch.js.map +1 -1
  97. package/dist/backend/llvm/lib-network.js +33 -6
  98. package/dist/backend/llvm/lib-network.js.map +1 -1
  99. package/dist/backend/llvm/lib-process.js +44 -3
  100. package/dist/backend/llvm/lib-process.js.map +1 -1
  101. package/dist/backend/llvm/lib-shared.js +69 -2
  102. package/dist/backend/llvm/lib-shared.js.map +1 -1
  103. package/dist/backend/llvm/local-union-storage.test.js +32 -0
  104. package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
  105. package/dist/backend/llvm/loop-state.js +7 -2
  106. package/dist/backend/llvm/loop-state.js.map +1 -1
  107. package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
  108. package/dist/backend/llvm/map-entry-fusion.js +3 -3
  109. package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
  110. package/dist/backend/llvm/map-number-lookup.test.js +6 -6
  111. package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
  112. package/dist/backend/llvm/nullable-unions.js +7 -6
  113. package/dist/backend/llvm/nullable-unions.js.map +1 -1
  114. package/dist/backend/llvm/nullable-unions.test.js +4 -1
  115. package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
  116. package/dist/backend/llvm/receivers.js +3 -0
  117. package/dist/backend/llvm/receivers.js.map +1 -1
  118. package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
  119. package/dist/backend/llvm/record-entry-fusion.js +217 -0
  120. package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
  121. package/dist/backend/llvm/record-results.d.ts +5 -2
  122. package/dist/backend/llvm/record-results.js +13 -12
  123. package/dist/backend/llvm/record-results.js.map +1 -1
  124. package/dist/backend/llvm/record-views.js +12 -6
  125. package/dist/backend/llvm/record-views.js.map +1 -1
  126. package/dist/backend/llvm/reference-effects.js +1 -0
  127. package/dist/backend/llvm/reference-effects.js.map +1 -1
  128. package/dist/backend/llvm/reference-writes.js +3 -0
  129. package/dist/backend/llvm/reference-writes.js.map +1 -1
  130. package/dist/backend/llvm/region-ir.js +1 -0
  131. package/dist/backend/llvm/region-ir.js.map +1 -1
  132. package/dist/backend/llvm/region-sites.d.ts +18 -0
  133. package/dist/backend/llvm/region-sites.js +79 -1
  134. package/dist/backend/llvm/region-sites.js.map +1 -1
  135. package/dist/backend/llvm/runtime-registries.test.js +53 -6
  136. package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
  137. package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
  138. package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
  139. package/dist/backend/llvm/shapes.d.ts +33 -3
  140. package/dist/backend/llvm/shapes.js +183 -13
  141. package/dist/backend/llvm/shapes.js.map +1 -1
  142. package/dist/backend/llvm/stack-objects.d.ts +1 -2
  143. package/dist/backend/llvm/stack-objects.js +8 -5
  144. package/dist/backend/llvm/stack-objects.js.map +1 -1
  145. package/dist/backend/llvm/walkers.d.ts +12 -0
  146. package/dist/backend/llvm/walkers.js +46 -2
  147. package/dist/backend/llvm/walkers.js.map +1 -1
  148. package/dist/backend/may-throw.js +12 -2
  149. package/dist/backend/may-throw.js.map +1 -1
  150. package/dist/backend/may-throw.test.js +13 -0
  151. package/dist/backend/may-throw.test.js.map +1 -1
  152. package/dist/backend/native/contracts.d.ts +48 -8
  153. package/dist/backend/native/executable.js +55 -13
  154. package/dist/backend/native/executable.js.map +1 -1
  155. package/dist/backend/native/helper-identity-record.d.ts +11 -0
  156. package/dist/backend/native/helper-identity-record.js +76 -0
  157. package/dist/backend/native/helper-identity-record.js.map +1 -0
  158. package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
  159. package/dist/backend/native/helper-identity-record.test.js +101 -0
  160. package/dist/backend/native/helper-identity-record.test.js.map +1 -0
  161. package/dist/backend/native/library.js +9 -1
  162. package/dist/backend/native/library.js.map +1 -1
  163. package/dist/backend/native/runtime-inputs.js +4 -1
  164. package/dist/backend/native/runtime-inputs.js.map +1 -1
  165. package/dist/backend/native/vendor.d.ts +1 -1
  166. package/dist/backend/native/vendor.js +1 -1
  167. package/dist/backend/native/vendor.js.map +1 -1
  168. package/dist/backend/native-codegen-core.d.ts +13 -10
  169. package/dist/backend/native-codegen-core.js +26 -13
  170. package/dist/backend/native-codegen-core.js.map +1 -1
  171. package/dist/backend/native-codegen.js +27 -8
  172. package/dist/backend/native-codegen.js.map +1 -1
  173. package/dist/backend/native-codegen.test.js +110 -14
  174. package/dist/backend/native-codegen.test.js.map +1 -1
  175. package/dist/backend/native-link-info-core.d.ts +37 -8
  176. package/dist/backend/native-link-info-core.js.map +1 -1
  177. package/dist/backend/runtime-pack-core.d.ts +17 -2
  178. package/dist/backend/runtime-pack-core.js +18 -3
  179. package/dist/backend/runtime-pack-core.js.map +1 -1
  180. package/dist/backend/runtime-pack-targets.test.js +1 -1
  181. package/dist/backend/runtime-pack-targets.test.js.map +1 -1
  182. package/dist/backend/runtime-pack.test.js +211 -2
  183. package/dist/backend/runtime-pack.test.js.map +1 -1
  184. package/dist/backend/tree-classes.d.ts +42 -0
  185. package/dist/backend/tree-classes.js +723 -0
  186. package/dist/backend/tree-classes.js.map +1 -0
  187. package/dist/backend/tree-classes.test.d.ts +1 -0
  188. package/dist/backend/tree-classes.test.js +338 -0
  189. package/dist/backend/tree-classes.test.js.map +1 -0
  190. package/dist/backend/vendor-archives.d.ts +5 -1
  191. package/dist/backend/vendor-archives.js +51 -7
  192. package/dist/backend/vendor-archives.js.map +1 -1
  193. package/dist/backend/vendor-inputs.d.ts +25 -4
  194. package/dist/backend/vendor-inputs.js +68 -4
  195. package/dist/backend/vendor-inputs.js.map +1 -1
  196. package/dist/backend/vendor-inputs.test.js +35 -1
  197. package/dist/backend/vendor-inputs.test.js.map +1 -1
  198. package/dist/backend/warm-cache.js +1 -1
  199. package/dist/backend/warm-cache.js.map +1 -1
  200. package/dist/compat/fetch-profile.js +2 -2
  201. package/dist/coverage/report.js +47 -0
  202. package/dist/coverage/report.js.map +1 -1
  203. package/dist/coverage/surface-manifest.js +1 -1
  204. package/dist/diagnostics/codes.d.ts +8 -0
  205. package/dist/diagnostics/codes.js +8 -0
  206. package/dist/diagnostics/codes.js.map +1 -1
  207. package/dist/diagnostics/diagnostic.d.ts +27 -9
  208. package/dist/diagnostics/diagnostic.js +60 -19
  209. package/dist/diagnostics/diagnostic.js.map +1 -1
  210. package/dist/diagnostics/envelope.d.ts +18 -0
  211. package/dist/diagnostics/envelope.js.map +1 -1
  212. package/dist/executable/executable-cache.d.ts +21 -2
  213. package/dist/executable/executable-cache.js +21 -1
  214. package/dist/executable/executable-cache.js.map +1 -1
  215. package/dist/executable/executable-cache.test.js +123 -1
  216. package/dist/executable/executable-cache.test.js.map +1 -1
  217. package/dist/executable/prepare.js +199 -248
  218. package/dist/executable/prepare.js.map +1 -1
  219. package/dist/frontend/analysis.js +200 -18
  220. package/dist/frontend/analysis.js.map +1 -1
  221. package/dist/frontend/builtin-modules.d.ts +4 -0
  222. package/dist/frontend/builtin-modules.js +10 -0
  223. package/dist/frontend/builtin-modules.js.map +1 -1
  224. package/dist/frontend/early-errors.d.ts +12 -2
  225. package/dist/frontend/early-errors.js +535 -4
  226. package/dist/frontend/early-errors.js.map +1 -1
  227. package/dist/frontend/early-errors.test.js +165 -0
  228. package/dist/frontend/early-errors.test.js.map +1 -1
  229. package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
  230. package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
  231. package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
  232. package/dist/frontend/jsx-opinion-sites.test.js +86 -0
  233. package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
  234. package/dist/frontend/lib-exports.d.ts +23 -4
  235. package/dist/frontend/lib-exports.js +98 -26
  236. package/dist/frontend/lib-exports.js.map +1 -1
  237. package/dist/frontend/lowering/binding-analysis.js +21 -3
  238. package/dist/frontend/lowering/binding-analysis.js.map +1 -1
  239. package/dist/frontend/lowering/buffers.d.ts +8 -0
  240. package/dist/frontend/lowering/buffers.js +43 -0
  241. package/dist/frontend/lowering/buffers.js.map +1 -0
  242. package/dist/frontend/lowering/builtin-calls.js +4 -0
  243. package/dist/frontend/lowering/builtin-calls.js.map +1 -1
  244. package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
  245. package/dist/frontend/lowering/builtin-namespaces.js +24 -3
  246. package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
  247. package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
  248. package/dist/frontend/lowering/builtin-statics.js +407 -0
  249. package/dist/frontend/lowering/builtin-statics.js.map +1 -0
  250. package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
  251. package/dist/frontend/lowering/builtins/arguments.js +12 -0
  252. package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
  253. package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
  254. package/dist/frontend/lowering/builtins/atomics.js +87 -1
  255. package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
  256. package/dist/frontend/lowering/builtins/child-process-methods.js +2 -2
  257. package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
  258. package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
  259. package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
  260. package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
  261. package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
  262. package/dist/frontend/lowering/builtins/child-process.js +560 -27
  263. package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
  264. package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
  265. package/dist/frontend/lowering/builtins/compression.js +41 -21
  266. package/dist/frontend/lowering/builtins/compression.js.map +1 -1
  267. package/dist/frontend/lowering/builtins/constants.js +7 -2
  268. package/dist/frontend/lowering/builtins/constants.js.map +1 -1
  269. package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
  270. package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
  271. package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
  272. package/dist/frontend/lowering/builtins/json.js +4 -0
  273. package/dist/frontend/lowering/builtins/json.js.map +1 -1
  274. package/dist/frontend/lowering/builtins/module-calls.js +3 -1
  275. package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
  276. package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
  277. package/dist/frontend/lowering/builtins/numbers.js +10 -2
  278. package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
  279. package/dist/frontend/lowering/builtins/operating-system.d.ts +6 -3
  280. package/dist/frontend/lowering/builtins/operating-system.js +96 -16
  281. package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
  282. package/dist/frontend/lowering/builtins/process.d.ts +2 -2
  283. package/dist/frontend/lowering/builtins/process.js +103 -8
  284. package/dist/frontend/lowering/builtins/process.js.map +1 -1
  285. package/dist/frontend/lowering/builtins/promises.js +169 -8
  286. package/dist/frontend/lowering/builtins/promises.js.map +1 -1
  287. package/dist/frontend/lowering/builtins/properties.js +6 -2
  288. package/dist/frontend/lowering/builtins/properties.js.map +1 -1
  289. package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
  290. package/dist/frontend/lowering/builtins/readline.js +180 -36
  291. package/dist/frontend/lowering/builtins/readline.js.map +1 -1
  292. package/dist/frontend/lowering/builtins/url.js +35 -12
  293. package/dist/frontend/lowering/builtins/url.js.map +1 -1
  294. package/dist/frontend/lowering/builtins/webassembly.js +2 -0
  295. package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
  296. package/dist/frontend/lowering/call-arguments.d.ts +10 -0
  297. package/dist/frontend/lowering/call-arguments.js +37 -2
  298. package/dist/frontend/lowering/call-arguments.js.map +1 -1
  299. package/dist/frontend/lowering/call-signatures.d.ts +10 -0
  300. package/dist/frontend/lowering/call-signatures.js +103 -0
  301. package/dist/frontend/lowering/call-signatures.js.map +1 -1
  302. package/dist/frontend/lowering/class-construction.d.ts +14 -2
  303. package/dist/frontend/lowering/class-construction.js +99 -5
  304. package/dist/frontend/lowering/class-construction.js.map +1 -1
  305. package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +9 -0
  306. package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
  307. package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
  308. package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
  309. package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
  310. package/dist/frontend/lowering/class-prototypes.js +20 -15
  311. package/dist/frontend/lowering/class-prototypes.js.map +1 -1
  312. package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
  313. package/dist/frontend/lowering/class-runtime-statics.js +20 -1
  314. package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
  315. package/dist/frontend/lowering/class-unions.js +21 -4
  316. package/dist/frontend/lowering/class-unions.js.map +1 -1
  317. package/dist/frontend/lowering/coercions/function-adapters.js +9 -0
  318. package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
  319. package/dist/frontend/lowering/coercions/state.d.ts +8 -0
  320. package/dist/frontend/lowering/coercions/state.js +17 -0
  321. package/dist/frontend/lowering/coercions/state.js.map +1 -1
  322. package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
  323. package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
  324. package/dist/frontend/lowering/coercions/structural.js +10 -1
  325. package/dist/frontend/lowering/coercions/structural.js.map +1 -1
  326. package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
  327. package/dist/frontend/lowering/coercions/unions.js +54 -10
  328. package/dist/frontend/lowering/coercions/unions.js.map +1 -1
  329. package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
  330. package/dist/frontend/lowering/constructor-returns.js +284 -58
  331. package/dist/frontend/lowering/constructor-returns.js.map +1 -1
  332. package/dist/frontend/lowering/containers/array-callbacks.js +156 -62
  333. package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
  334. package/dist/frontend/lowering/containers/array-construction.js +21 -3
  335. package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
  336. package/dist/frontend/lowering/containers/array-from-async.js +139 -3
  337. package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
  338. package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
  339. package/dist/frontend/lowering/containers/array-iteration.js +24 -7
  340. package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
  341. package/dist/frontend/lowering/containers/array-methods.js +14 -11
  342. package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
  343. package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
  344. package/dist/frontend/lowering/containers/bytes.js +446 -86
  345. package/dist/frontend/lowering/containers/bytes.js.map +1 -1
  346. package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
  347. package/dist/frontend/lowering/containers/callback-arguments.js +21 -12
  348. package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
  349. package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
  350. package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
  351. package/dist/frontend/lowering/containers/collection-methods.js +52 -17
  352. package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
  353. package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
  354. package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
  355. package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
  356. package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
  357. package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
  358. package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
  359. package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
  360. package/dist/frontend/lowering/crypto-tables.js +5 -5
  361. package/dist/frontend/lowering/dispatch-sites.js +3 -0
  362. package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
  363. package/dist/frontend/lowering/divergences.d.ts +40 -0
  364. package/dist/frontend/lowering/divergences.js +239 -20
  365. package/dist/frontend/lowering/divergences.js.map +1 -1
  366. package/dist/frontend/lowering/effect-free.d.ts +12 -0
  367. package/dist/frontend/lowering/effect-free.js +44 -0
  368. package/dist/frontend/lowering/effect-free.js.map +1 -0
  369. package/dist/frontend/lowering/expressions/array-literals.d.ts +10 -0
  370. package/dist/frontend/lowering/expressions/array-literals.js +62 -0
  371. package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
  372. package/dist/frontend/lowering/expressions/binary.js +115 -5
  373. package/dist/frontend/lowering/expressions/binary.js.map +1 -1
  374. package/dist/frontend/lowering/expressions/element-access.js +151 -7
  375. package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
  376. package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
  377. package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
  378. package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
  379. package/dist/frontend/lowering/expressions/identifiers.js +31 -2
  380. package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
  381. package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
  382. package/dist/frontend/lowering/expressions/narrowing.js +175 -22
  383. package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
  384. package/dist/frontend/lowering/expressions/object-literals.js +173 -11
  385. package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
  386. package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
  387. package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
  388. package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
  389. package/dist/frontend/lowering/expressions/property-access.js +379 -109
  390. package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
  391. package/dist/frontend/lowering/expressions/relational.js +237 -7
  392. package/dist/frontend/lowering/expressions/relational.js.map +1 -1
  393. package/dist/frontend/lowering/expressions/typeof.js +8 -0
  394. package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
  395. package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
  396. package/dist/frontend/lowering/expressions/union-fields.js +103 -13
  397. package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
  398. package/dist/frontend/lowering/expressions/updates.js +74 -55
  399. package/dist/frontend/lowering/expressions/updates.js.map +1 -1
  400. package/dist/frontend/lowering/function-returns.js +37 -10
  401. package/dist/frontend/lowering/function-returns.js.map +1 -1
  402. package/dist/frontend/lowering/general-streams.js +5 -0
  403. package/dist/frontend/lowering/general-streams.js.map +1 -1
  404. package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
  405. package/dist/frontend/lowering/generator-delegation.js +301 -118
  406. package/dist/frontend/lowering/generator-delegation.js.map +1 -1
  407. package/dist/frontend/lowering/generic-functions.d.ts +27 -1
  408. package/dist/frontend/lowering/generic-functions.js +432 -18
  409. package/dist/frontend/lowering/generic-functions.js.map +1 -1
  410. package/dist/frontend/lowering/global-function-values.d.ts +25 -0
  411. package/dist/frontend/lowering/global-function-values.js +193 -0
  412. package/dist/frontend/lowering/global-function-values.js.map +1 -0
  413. package/dist/frontend/lowering/global-values.d.ts +6 -4
  414. package/dist/frontend/lowering/global-values.js +24 -10
  415. package/dist/frontend/lowering/global-values.js.map +1 -1
  416. package/dist/frontend/lowering/host-global-values.d.ts +31 -0
  417. package/dist/frontend/lowering/host-global-values.js +121 -0
  418. package/dist/frontend/lowering/host-global-values.js.map +1 -0
  419. package/dist/frontend/lowering/host-globals.d.ts +74 -0
  420. package/dist/frontend/lowering/host-globals.js +344 -0
  421. package/dist/frontend/lowering/host-globals.js.map +1 -0
  422. package/dist/frontend/lowering/http2-constants.js +1 -1
  423. package/dist/frontend/lowering/iterator-adapters.js +46 -17
  424. package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
  425. package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
  426. package/dist/frontend/lowering/iterator-prototype.js +160 -0
  427. package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
  428. package/dist/frontend/lowering/key-order-witness.js +43 -22
  429. package/dist/frontend/lowering/key-order-witness.js.map +1 -1
  430. package/dist/frontend/lowering/key-order-witness.test.js +1 -0
  431. package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
  432. package/dist/frontend/lowering/lib-boundary.js +11 -3
  433. package/dist/frontend/lowering/lib-boundary.js.map +1 -1
  434. package/dist/frontend/lowering/lower-assert.js +30 -15
  435. package/dist/frontend/lowering/lower-assert.js.map +1 -1
  436. package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
  437. package/dist/frontend/lowering/lower-async-iteration.js +15 -0
  438. package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
  439. package/dist/frontend/lowering/lower-builtin-values.js +11 -1
  440. package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
  441. package/dist/frontend/lowering/lower-calls.d.ts +25 -0
  442. package/dist/frontend/lowering/lower-calls.js +929 -227
  443. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  444. package/dist/frontend/lowering/lower-calls.test.js +59 -16
  445. package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
  446. package/dist/frontend/lowering/lower-classes.d.ts +20 -0
  447. package/dist/frontend/lowering/lower-classes.js +468 -44
  448. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  449. package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
  450. package/dist/frontend/lowering/lower-event-emitter.js +253 -83
  451. package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
  452. package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
  453. package/dist/frontend/lowering/lower-exprs.js +71 -20
  454. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  455. package/dist/frontend/lowering/lower-functions.js +25 -6
  456. package/dist/frontend/lowering/lower-functions.js.map +1 -1
  457. package/dist/frontend/lowering/lower-generators.js +57 -10
  458. package/dist/frontend/lowering/lower-generators.js.map +1 -1
  459. package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
  460. package/dist/frontend/lowering/lower-global-value.js +14 -5
  461. package/dist/frontend/lowering/lower-global-value.js.map +1 -1
  462. package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
  463. package/dist/frontend/lowering/lower-inspect.js +638 -64
  464. package/dist/frontend/lowering/lower-inspect.js.map +1 -1
  465. package/dist/frontend/lowering/lower-modules.js +48 -2
  466. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  467. package/dist/frontend/lowering/lower-namespaces.js +18 -0
  468. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  469. package/dist/frontend/lowering/lower-node-island.js +16 -6
  470. package/dist/frontend/lowering/lower-node-island.js.map +1 -1
  471. package/dist/frontend/lowering/lower-server.js +303 -87
  472. package/dist/frontend/lowering/lower-server.js.map +1 -1
  473. package/dist/frontend/lowering/lower-stdlib.js +45 -0
  474. package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
  475. package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
  476. package/dist/frontend/lowering/lower-stmts.js +270 -52
  477. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  478. package/dist/frontend/lowering/lower-timers.js +110 -27
  479. package/dist/frontend/lowering/lower-timers.js.map +1 -1
  480. package/dist/frontend/lowering/lower-url.js +6 -3
  481. package/dist/frontend/lowering/lower-url.js.map +1 -1
  482. package/dist/frontend/lowering/lowerer.d.ts +227 -21
  483. package/dist/frontend/lowering/lowerer.js +651 -92
  484. package/dist/frontend/lowering/lowerer.js.map +1 -1
  485. package/dist/frontend/lowering/lowerer.test.js +18 -0
  486. package/dist/frontend/lowering/lowerer.test.js.map +1 -1
  487. package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
  488. package/dist/frontend/lowering/lowering-facts.js +323 -0
  489. package/dist/frontend/lowering/lowering-facts.js.map +1 -0
  490. package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
  491. package/dist/frontend/lowering/lowering-facts.test.js +100 -0
  492. package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
  493. package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
  494. package/dist/frontend/lowering/nan-coded-reads.js +112 -9
  495. package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
  496. package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
  497. package/dist/frontend/lowering/optional-arguments.js +26 -2
  498. package/dist/frontend/lowering/optional-arguments.js.map +1 -1
  499. package/dist/frontend/lowering/partial-assertions.d.ts +0 -3
  500. package/dist/frontend/lowering/partial-assertions.js +9 -15
  501. package/dist/frontend/lowering/partial-assertions.js.map +1 -1
  502. package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
  503. package/dist/frontend/lowering/primitive-throws.js +241 -0
  504. package/dist/frontend/lowering/primitive-throws.js.map +1 -0
  505. package/dist/frontend/lowering/primitive-wrappers.js +1 -0
  506. package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
  507. package/dist/frontend/lowering/record-inherited.d.ts +17 -1
  508. package/dist/frontend/lowering/record-inherited.js +16 -2
  509. package/dist/frontend/lowering/record-inherited.js.map +1 -1
  510. package/dist/frontend/lowering/record-links.d.ts +73 -0
  511. package/dist/frontend/lowering/record-links.js +797 -0
  512. package/dist/frontend/lowering/record-links.js.map +1 -0
  513. package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
  514. package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
  515. package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
  516. package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
  517. package/dist/frontend/lowering/runtime-optional-report.js +300 -0
  518. package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
  519. package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
  520. package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
  521. package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
  522. package/dist/frontend/lowering/static-typeof.d.ts +3 -1
  523. package/dist/frontend/lowering/static-typeof.js +6 -1
  524. package/dist/frontend/lowering/static-typeof.js.map +1 -1
  525. package/dist/frontend/lowering/strict-mode.d.ts +1 -5
  526. package/dist/frontend/lowering/strict-mode.js +4 -30
  527. package/dist/frontend/lowering/strict-mode.js.map +1 -1
  528. package/dist/frontend/lowering/structural-instances.d.ts +7 -0
  529. package/dist/frontend/lowering/structural-instances.js +23 -0
  530. package/dist/frontend/lowering/structural-instances.js.map +1 -1
  531. package/dist/frontend/lowering/surfaces.d.ts +15 -1
  532. package/dist/frontend/lowering/surfaces.js +78 -10
  533. package/dist/frontend/lowering/surfaces.js.map +1 -1
  534. package/dist/frontend/lowering/union-retag.d.ts +13 -1
  535. package/dist/frontend/lowering/union-retag.js +55 -1
  536. package/dist/frontend/lowering/union-retag.js.map +1 -1
  537. package/dist/frontend/lowering/union-retag.test.js +51 -0
  538. package/dist/frontend/lowering/union-retag.test.js.map +1 -1
  539. package/dist/frontend/lowering/unit-journal.d.ts +8 -0
  540. package/dist/frontend/lowering/unit-journal.js +14 -0
  541. package/dist/frontend/lowering/unit-journal.js.map +1 -1
  542. package/dist/frontend/lowering/unit-journal.test.js +36 -1
  543. package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
  544. package/dist/frontend/lowering/zlib-constants.js +3 -2
  545. package/dist/frontend/lowering/zlib-constants.js.map +1 -1
  546. package/dist/frontend/npm-static.js +78 -9
  547. package/dist/frontend/npm-static.js.map +1 -1
  548. package/dist/frontend/npm-static.test.js +95 -2
  549. package/dist/frontend/npm-static.test.js.map +1 -1
  550. package/dist/frontend/pipeline.d.ts +5 -4
  551. package/dist/frontend/pipeline.js +94 -31
  552. package/dist/frontend/pipeline.js.map +1 -1
  553. package/dist/frontend/pipeline.test.js +68 -11
  554. package/dist/frontend/pipeline.test.js.map +1 -1
  555. package/dist/frontend/program.d.ts +62 -2
  556. package/dist/frontend/program.js +695 -422
  557. package/dist/frontend/program.js.map +1 -1
  558. package/dist/frontend/program.test.js +37 -1
  559. package/dist/frontend/program.test.js.map +1 -1
  560. package/dist/frontend/services-node.d.ts +7 -0
  561. package/dist/frontend/services-node.js +32 -1
  562. package/dist/frontend/services-node.js.map +1 -1
  563. package/dist/frontend/services-node.test.js +51 -0
  564. package/dist/frontend/services-node.test.js.map +1 -1
  565. package/dist/frontend/shape-inference/overlay.js +68 -2
  566. package/dist/frontend/shape-inference/overlay.js.map +1 -1
  567. package/dist/frontend/tier-analysis.d.ts +9 -0
  568. package/dist/frontend/tier-analysis.js +1 -0
  569. package/dist/frontend/tier-analysis.js.map +1 -1
  570. package/dist/frontend/tsc-codes.d.ts +57 -3
  571. package/dist/frontend/tsc-codes.js +935 -150
  572. package/dist/frontend/tsc-codes.js.map +1 -1
  573. package/dist/frontend/tsc-codes.test.js +221 -12
  574. package/dist/frontend/tsc-codes.test.js.map +1 -1
  575. package/dist/frontend/type-mapper.d.ts +91 -9
  576. package/dist/frontend/type-mapper.js +622 -181
  577. package/dist/frontend/type-mapper.js.map +1 -1
  578. package/dist/index.d.ts +1 -1
  579. package/dist/index.js +80 -15
  580. package/dist/index.js.map +1 -1
  581. package/dist/index.test.d.ts +1 -0
  582. package/dist/index.test.js +60 -0
  583. package/dist/index.test.js.map +1 -0
  584. package/dist/ir/builtin-effects.js +43 -0
  585. package/dist/ir/builtin-effects.js.map +1 -1
  586. package/dist/ir/builtin-signatures.d.ts +1 -1
  587. package/dist/ir/builtin-signatures.js +242 -16
  588. package/dist/ir/builtin-signatures.js.map +1 -1
  589. package/dist/ir/callback-specialization.d.ts +3 -2
  590. package/dist/ir/callback-specialization.js +35 -25
  591. package/dist/ir/callback-specialization.js.map +1 -1
  592. package/dist/ir/capture-values.d.ts +8 -4
  593. package/dist/ir/capture-values.js +9 -6
  594. package/dist/ir/capture-values.js.map +1 -1
  595. package/dist/ir/char-unit-locals.d.ts +6 -2
  596. package/dist/ir/char-unit-locals.js +11 -2
  597. package/dist/ir/char-unit-locals.js.map +1 -1
  598. package/dist/ir/class-key-index.d.ts +18 -0
  599. package/dist/ir/class-key-index.js +29 -0
  600. package/dist/ir/class-key-index.js.map +1 -0
  601. package/dist/ir/class-key-index.test.d.ts +1 -0
  602. package/dist/ir/class-key-index.test.js +25 -0
  603. package/dist/ir/class-key-index.test.js.map +1 -0
  604. package/dist/ir/codec.generated.d.ts +1 -1
  605. package/dist/ir/codec.generated.js +724 -648
  606. package/dist/ir/codec.generated.js.map +1 -1
  607. package/dist/ir/constant-globals.d.ts +5 -2
  608. package/dist/ir/constant-globals.js +25 -27
  609. package/dist/ir/constant-globals.js.map +1 -1
  610. package/dist/ir/expression-inlining.d.ts +4 -2
  611. package/dist/ir/expression-inlining.js +8 -2
  612. package/dist/ir/expression-inlining.js.map +1 -1
  613. package/dist/ir/field-values.d.ts +5 -2
  614. package/dist/ir/field-values.js +32 -21
  615. package/dist/ir/field-values.js.map +1 -1
  616. package/dist/ir/fields.generated.d.ts +11 -2
  617. package/dist/ir/fields.generated.js +8 -0
  618. package/dist/ir/fields.generated.js.map +1 -1
  619. package/dist/ir/final-fields.js +1 -1
  620. package/dist/ir/final-fields.js.map +1 -1
  621. package/dist/ir/function-references.d.ts +5 -4
  622. package/dist/ir/function-references.js +7 -4
  623. package/dist/ir/function-references.js.map +1 -1
  624. package/dist/ir/function-references.test.js +7 -0
  625. package/dist/ir/function-references.test.js.map +1 -1
  626. package/dist/ir/init-only-globals.d.ts +4 -2
  627. package/dist/ir/init-only-globals.js +17 -18
  628. package/dist/ir/init-only-globals.js.map +1 -1
  629. package/dist/ir/inline-array-views.js +1 -0
  630. package/dist/ir/inline-array-views.js.map +1 -1
  631. package/dist/ir/int32-slots.js +7 -0
  632. package/dist/ir/int32-slots.js.map +1 -1
  633. package/dist/ir/ir.d.ts +59 -4
  634. package/dist/ir/ir.js +7 -0
  635. package/dist/ir/ir.js.map +1 -1
  636. package/dist/ir/js-groups.d.ts +51 -0
  637. package/dist/ir/js-groups.js +394 -0
  638. package/dist/ir/js-groups.js.map +1 -0
  639. package/dist/ir/js-groups.test.d.ts +1 -0
  640. package/dist/ir/js-groups.test.js +555 -0
  641. package/dist/ir/js-groups.test.js.map +1 -0
  642. package/dist/ir/js-ic.js +30 -5
  643. package/dist/ir/js-ic.js.map +1 -1
  644. package/dist/ir/js-ic.test.js +27 -1
  645. package/dist/ir/js-ic.test.js.map +1 -1
  646. package/dist/ir/node-index.d.ts +23 -6
  647. package/dist/ir/node-index.js +126 -49
  648. package/dist/ir/node-index.js.map +1 -1
  649. package/dist/ir/numeric-call-specialization.d.ts +4 -2
  650. package/dist/ir/numeric-call-specialization.js +40 -26
  651. package/dist/ir/numeric-call-specialization.js.map +1 -1
  652. package/dist/ir/paired-while-loops.d.ts +4 -2
  653. package/dist/ir/paired-while-loops.js +8 -2
  654. package/dist/ir/paired-while-loops.js.map +1 -1
  655. package/dist/ir/parameter-versions.d.ts +13 -4
  656. package/dist/ir/parameter-versions.js +63 -42
  657. package/dist/ir/parameter-versions.js.map +1 -1
  658. package/dist/ir/property-bags.d.ts +4 -2
  659. package/dist/ir/property-bags.js +22 -17
  660. package/dist/ir/property-bags.js.map +1 -1
  661. package/dist/ir/row-pairs.d.ts +4 -2
  662. package/dist/ir/row-pairs.js +12 -11
  663. package/dist/ir/row-pairs.js.map +1 -1
  664. package/dist/ir/runtime-features.d.ts +87 -12
  665. package/dist/ir/runtime-features.js +263 -160
  666. package/dist/ir/runtime-features.js.map +1 -1
  667. package/dist/ir/runtime-features.test.js +109 -139
  668. package/dist/ir/runtime-features.test.js.map +1 -1
  669. package/dist/ir/runtime-jam-loops.d.ts +35 -0
  670. package/dist/ir/runtime-jam-loops.js +604 -0
  671. package/dist/ir/runtime-jam-loops.js.map +1 -0
  672. package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
  673. package/dist/ir/runtime-jam-loops.test.js +565 -0
  674. package/dist/ir/runtime-jam-loops.test.js.map +1 -0
  675. package/dist/ir/saturating-loop-jams.d.ts +4 -2
  676. package/dist/ir/saturating-loop-jams.js +11 -10
  677. package/dist/ir/saturating-loop-jams.js.map +1 -1
  678. package/dist/ir/scalar-records.d.ts +5 -2
  679. package/dist/ir/scalar-records.js +12 -2
  680. package/dist/ir/scalar-records.js.map +1 -1
  681. package/dist/ir/self-captures.d.ts +4 -2
  682. package/dist/ir/self-captures.js +32 -27
  683. package/dist/ir/self-captures.js.map +1 -1
  684. package/dist/ir/serialize.d.ts +6 -1
  685. package/dist/ir/serialize.js +87 -23
  686. package/dist/ir/serialize.js.map +1 -1
  687. package/dist/ir/serialize.test.js +26 -0
  688. package/dist/ir/serialize.test.js.map +1 -1
  689. package/dist/ir/tiers.js +1 -0
  690. package/dist/ir/tiers.js.map +1 -1
  691. package/dist/ir/traverse.js +4 -0
  692. package/dist/ir/traverse.js.map +1 -1
  693. package/dist/ir/typed-argument-clones.d.ts +30 -0
  694. package/dist/ir/typed-argument-clones.js +789 -0
  695. package/dist/ir/typed-argument-clones.js.map +1 -0
  696. package/dist/ir/union-arm-loops.d.ts +3 -0
  697. package/dist/ir/union-arm-loops.js +373 -0
  698. package/dist/ir/union-arm-loops.js.map +1 -0
  699. package/dist/ir/union-arm-loops.test.d.ts +1 -0
  700. package/dist/ir/union-arm-loops.test.js +230 -0
  701. package/dist/ir/union-arm-loops.test.js.map +1 -0
  702. package/dist/ir/validate.js +88 -18
  703. package/dist/ir/validate.js.map +1 -1
  704. package/dist/library/compiler-self-identity.d.ts +8 -2
  705. package/dist/library/compiler-self-identity.js +92 -18
  706. package/dist/library/compiler-self-identity.js.map +1 -1
  707. package/dist/library/compiler-self-identity.test.js +150 -3
  708. package/dist/library/compiler-self-identity.test.js.map +1 -1
  709. package/dist/library/int-infer.d.ts +5 -0
  710. package/dist/library/int-infer.js +15 -3
  711. package/dist/library/int-infer.js.map +1 -1
  712. package/dist/library/ir-policy.js +1 -0
  713. package/dist/library/ir-policy.js.map +1 -1
  714. package/dist/library/library-cache.d.ts +4 -0
  715. package/dist/library/library-cache.js +2 -0
  716. package/dist/library/library-cache.js.map +1 -1
  717. package/dist/library/library-cache.test.js +26 -0
  718. package/dist/library/library-cache.test.js.map +1 -1
  719. package/dist/library/prepare.js +99 -31
  720. package/dist/library/prepare.js.map +1 -1
  721. package/dist/native/cache.d.ts +7 -0
  722. package/dist/native/cache.js +47 -0
  723. package/dist/native/cache.js.map +1 -1
  724. package/dist/native/cache.test.js +13 -1
  725. package/dist/native/cache.test.js.map +1 -1
  726. package/dist/native/cli.js +1 -1
  727. package/dist/native/cli.js.map +1 -1
  728. package/dist/native/compiler.js +18 -3
  729. package/dist/native/compiler.js.map +1 -1
  730. package/dist/native/executable-cache-open.test.js +31 -5
  731. package/dist/native/executable-cache-open.test.js.map +1 -1
  732. package/dist/native/executable-cache.d.ts +6 -1
  733. package/dist/native/executable-cache.js +7 -1
  734. package/dist/native/executable-cache.js.map +1 -1
  735. package/dist/native/prepare.d.ts +3 -0
  736. package/dist/native/prepare.js +43 -26
  737. package/dist/native/prepare.js.map +1 -1
  738. package/dist/native/prepare.test.js +25 -3
  739. package/dist/native/prepare.test.js.map +1 -1
  740. package/dist/native/sanitizer.js +10 -1
  741. package/dist/native/sanitizer.js.map +1 -1
  742. package/dist/native/sanitizer.test.js +7 -2
  743. package/dist/native/sanitizer.test.js.map +1 -1
  744. package/dist/node-islands/boundary.d.ts +12 -0
  745. package/dist/node-islands/boundary.js +38 -6
  746. package/dist/node-islands/boundary.js.map +1 -1
  747. package/dist/node-islands/boundary.test.d.ts +1 -0
  748. package/dist/node-islands/boundary.test.js +76 -0
  749. package/dist/node-islands/boundary.test.js.map +1 -0
  750. package/dist/node-islands/detect.d.ts +9 -0
  751. package/dist/node-islands/detect.js +110 -0
  752. package/dist/node-islands/detect.js.map +1 -1
  753. package/dist/node-islands/detect.test.js +24 -0
  754. package/dist/node-islands/detect.test.js.map +1 -1
  755. package/dist/node-islands/graph-islands.d.ts +40 -0
  756. package/dist/node-islands/graph-islands.js +128 -0
  757. package/dist/node-islands/graph-islands.js.map +1 -0
  758. package/dist/node-islands/growth.d.ts +57 -0
  759. package/dist/node-islands/growth.js +205 -0
  760. package/dist/node-islands/growth.js.map +1 -0
  761. package/dist/node-islands/report.d.ts +12 -0
  762. package/dist/node-islands/report.js +28 -0
  763. package/dist/node-islands/report.js.map +1 -1
  764. package/dist/node-islands/report.test.js +2 -0
  765. package/dist/node-islands/report.test.js.map +1 -1
  766. package/dist/node-islands/rules.js +5 -0
  767. package/dist/node-islands/rules.js.map +1 -1
  768. package/dist/node-islands/scan.d.ts +11 -2
  769. package/dist/node-islands/scan.js +61 -9
  770. package/dist/node-islands/scan.js.map +1 -1
  771. package/dist/wasm/translate.js +11 -5
  772. package/dist/wasm/translate.js.map +1 -1
  773. package/dist/wasm/translate.test.js +35 -0
  774. package/dist/wasm/translate.test.js.map +1 -1
  775. package/package.json +20 -20
  776. package/surface-manifest.json +184 -117
@@ -1146,11 +1146,57 @@ export function isDeclaredInAmbientNamespace(d, name) {
1146
1146
  }
1147
1147
  return false;
1148
1148
  }
1149
+ /** The answers provenanceOf has given, keyed by symbol. The lowering owns
1150
+ * one map through TypeMapperCtx.symbolProvenance; a symbol belongs to one
1151
+ * loaded program, so one island round shares the map across its passes
1152
+ * (lowering-facts.ts). */
1153
+ export function newSymbolProvenanceMemo() {
1154
+ return new Map();
1155
+ }
1156
+ /** A symbol's provenance, computed from its declarations alone: the answer
1157
+ * depends on which files declare it and nothing else, so it is the same for
1158
+ * every lowering pass of one loaded program (lowering-facts.ts shares the
1159
+ * memo). */
1160
+ export function computeSymbolProvenance(psym, isStdlibFile) {
1161
+ let stdlibInterface = false;
1162
+ let stdlibClass = false;
1163
+ let libInterface = false;
1164
+ for (const decl of psym.declarations) {
1165
+ const file = ts.getSourceFileOfNode(decl);
1166
+ if (!isStdlibFile(file))
1167
+ continue;
1168
+ if (ts.isInterfaceDeclaration(decl)) {
1169
+ stdlibInterface = true;
1170
+ stdlibClass = true;
1171
+ if (!isNodeTypesPath(file.fileName))
1172
+ libInterface = true;
1173
+ }
1174
+ else if (ts.isClassDeclaration(decl)) {
1175
+ stdlibClass = true;
1176
+ }
1177
+ }
1178
+ return { stdlibInterface, stdlibClass, libInterface };
1179
+ }
1180
+ function provenanceOf(psym, ctx) {
1181
+ let bySymbol = ctx.symbolProvenance;
1182
+ if (bySymbol === undefined) {
1183
+ bySymbol = new Map();
1184
+ ctx.symbolProvenance = bySymbol;
1185
+ }
1186
+ let provenance = bySymbol.get(psym);
1187
+ if (provenance === undefined) {
1188
+ provenance = computeSymbolProvenance(psym, ctx.isStdlibFile);
1189
+ bySymbol.set(psym, provenance);
1190
+ }
1191
+ else
1192
+ ctx.verifySymbolProvenance?.(psym, provenance);
1193
+ return provenance;
1194
+ }
1149
1195
  /** Whether `type` is one of the stream spellings the general stream
1150
1196
  * representation (TypeMapperCtx.generalNodeStreams) maps differently:
1151
1197
  * NodeJS.ReadableStream / NodeJS.WritableStream, @types/node's
1152
1198
  * stream.Readable / stream.Writable, or the fallback declarations'
1153
- * ChildStdin. */
1199
+ * ChildStdin / ChildStdout. */
1154
1200
  export function isGeneralNodeStreamInterface(type, ctx) {
1155
1201
  const psym = type.getSymbol() ?? type.getAliasSymbol();
1156
1202
  if (psym === undefined)
@@ -1162,13 +1208,21 @@ export function isGeneralNodeStreamInterface(type, ctx) {
1162
1208
  return false;
1163
1209
  if (ts.symbolName(psym) === "ReadableStream" || ts.symbolName(psym) === "WritableStream")
1164
1210
  return ts.isInterfaceDeclaration(d) && isDeclaredInAmbientNamespace(d, "NodeJS");
1165
- if (ts.symbolName(psym) === "ChildStdin")
1211
+ if (ts.symbolName(psym) === "ChildStdin" || ts.symbolName(psym) === "ChildStdout")
1166
1212
  return isDeclaredInAmbientModule(d, "child_process");
1167
1213
  return ((ts.symbolName(psym) === "Readable" || ts.symbolName(psym) === "Writable") &&
1168
1214
  isNodeTypesPath(ts.getSourceFileOfNode(d).fileName) &&
1169
1215
  isDeclaredInAmbientModule(d, "stream"));
1170
1216
  });
1171
1217
  }
1218
+ /** Whether any declaration of the symbol sits in the shipped WebAssembly
1219
+ * namespace (scriptc.d.ts). Like the declaration-kind walk, the answer is a
1220
+ * function of the declarations alone, so provenanceOf's shared memo can keep
1221
+ * it (SymbolProvenance.webAssembly). */
1222
+ export function declaresWebAssemblyNamespace(declarations, isStdlibFile) {
1223
+ return declarations.some((d) => isStdlibFile(ts.getSourceFileOfNode(d)) &&
1224
+ isDeclaredInAmbientNamespace(d, "WebAssembly"));
1225
+ }
1172
1226
  /** A type declared in the shipped WebAssembly namespace (scriptc.d.ts):
1173
1227
  * its modules, instances, memories, tables, globals, error classes and the
1174
1228
  * Exports/Imports records. */
@@ -1176,8 +1230,9 @@ export function isWebAssemblyType(type, ctx) {
1176
1230
  const symbol = type.getAliasSymbol() ?? type.getSymbol();
1177
1231
  if (!symbol)
1178
1232
  return false;
1179
- return symbol.declarations.some((d) => ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
1180
- isDeclaredInAmbientNamespace(d, "WebAssembly"));
1233
+ const provenance = provenanceOf(symbol, ctx);
1234
+ provenance.webAssembly ??= declaresWebAssemblyNamespace(symbol.declarations, ctx.isStdlibFile);
1235
+ return provenance.webAssembly;
1181
1236
  }
1182
1237
  /** True when a type contains a record anywhere (the trigger for the
1183
1238
  * shape-mismatch diagnostic SC2002 — non-record mismatches are tsc's or
@@ -1291,6 +1346,37 @@ let mapTypeDepth = 0;
1291
1346
  * a bump between entry and exit stays fenced (recursive generic-open types
1292
1347
  * stay fenced instead of interning a per-context-wrong shape). */
1293
1348
  let contextResolutions = 0;
1349
+ /** Bumped whenever a mapping reads state that only a generic-INSTANTIATION
1350
+ * scope installs: a type-parameter binding (the Lowerer's resolver hooks,
1351
+ * consulted whether or not bindings are installed right now — the same
1352
+ * checker type parameter answers differently with and without them), the
1353
+ * instance's result class, or the local-class instantiation stack. The
1354
+ * answer of such a mapping can differ from one instance to the next, so it
1355
+ * stays in that scope's memo (Lowerer.currentTypeMemo). A mapping that reads
1356
+ * none of it is the answer every scope gives, and may serve all of them
1357
+ * (TypeMapperCtx.typeMemoShared). */
1358
+ let scopeSensitivity = 0;
1359
+ /** Notes that the mapping in progress read generic-instantiation scope state. */
1360
+ export function noteScopeSensitiveMapping() {
1361
+ scopeSensitivity++;
1362
+ }
1363
+ /** SCRIPTC_TYPE_MEMO_VERIFY=1: every hit on a shared (scope-independent)
1364
+ * memo entry is recomputed from scratch in the scope that took it and
1365
+ * compared. A mismatch is a miscompile the sharing would have introduced,
1366
+ * so the mode throws instead of quietly recomputing: it exists to prove the
1367
+ * sharing on a corpus, never to rescue it at run time. `=stats` also prints
1368
+ * how many hits it checked when the process exits. */
1369
+ const verifyMemoMode = process.env["SCRIPTC_TYPE_MEMO_VERIFY"] ?? "";
1370
+ const verifySharedTypeMemo = verifyMemoMode === "1" || verifyMemoMode === "stats";
1371
+ let verifiedSharedHits = 0;
1372
+ if (verifyMemoMode === "stats") {
1373
+ process.on("exit", () => {
1374
+ process.stderr.write(`[type-memo] verified ${verifiedSharedHits} shared memo hits\n`);
1375
+ });
1376
+ }
1377
+ /** Set while verifying, so the recomputation bypasses every memo and does
1378
+ * not verify itself. */
1379
+ let bypassTypeMemo = false;
1294
1380
  /** node:url's legacy record interfaces: url.parse()'s Url instance (and
1295
1381
  * its two query-typed refinements), url.format()'s UrlObject input, the
1296
1382
  * URL form's URLFormatOptions, and urlToHttpOptions's result. The values
@@ -1314,7 +1400,15 @@ export function isLegacyUrlType(type, ctx) {
1314
1400
  export function isLegacyUrlSymbol(symbol, ctx) {
1315
1401
  if (!symbol)
1316
1402
  return false;
1317
- for (const d of symbol.declarations) {
1403
+ const provenance = provenanceOf(symbol, ctx);
1404
+ provenance.legacyUrl ??= declaresLegacyUrl(symbol.declarations, ctx);
1405
+ return provenance.legacyUrl;
1406
+ }
1407
+ /** Whether any declaration of the symbol is one of node:url's legacy record
1408
+ * interfaces (or a member of one). A function of the declarations alone,
1409
+ * stored as SymbolProvenance.legacyUrl in provenanceOf's shared memo. */
1410
+ export function declaresLegacyUrl(declarations, ctx) {
1411
+ for (const d of declarations) {
1318
1412
  if (!ctx.isStdlibFile(ts.getSourceFileOfNode(d)))
1319
1413
  continue;
1320
1414
  let family = false;
@@ -1686,12 +1780,34 @@ function mapTypeEntry(type, ctx) {
1686
1780
  // arm (emptyLiteralArm) and to the checked-dynamic value elsewhere: the two
1687
1781
  // answers keep separate memo entries. Type ids are non-negative integers.
1688
1782
  const memoKey = memoizable ? typeId * 2 + (ctx.emptyLiteralArm ? 1 : 0) : null;
1689
- if (memoKey !== null) {
1690
- const memo = ctx.typeMemo?.get(memoKey);
1691
- if (memo !== undefined)
1692
- return memo;
1783
+ /** The memo of the binding context this frame started in: the scope's own
1784
+ * inside generic bindings, the lowerer's top-level memo outside them. */
1785
+ let contextMemo;
1786
+ if (memoKey !== null && !bypassTypeMemo) {
1787
+ contextMemo = ctx.typeMemoFor?.() ?? ctx.typeMemo;
1788
+ const own = contextMemo?.get(memoKey);
1789
+ if (own !== undefined) {
1790
+ // The scope's own memo also holds answers this scope's bindings shaped
1791
+ // (they were written here, not shared). Taking one re-reads that
1792
+ // scope state just as mapping the type would, so the frame that took it
1793
+ // is scope-specific too: without this the parent could enter the shared
1794
+ // memo and serve this instance's representation to every later one.
1795
+ if (ctx.typeMemoShared?.get(memoKey) !== own)
1796
+ noteScopeSensitiveMapping();
1797
+ return own;
1798
+ }
1799
+ const shared = ctx.typeMemoShared;
1800
+ if (shared !== undefined && shared !== contextMemo) {
1801
+ const hit = shared.get(memoKey);
1802
+ if (hit !== undefined) {
1803
+ if (verifySharedTypeMemo && topLevel)
1804
+ verifySharedMapping(type, ctx, hit);
1805
+ return hit;
1806
+ }
1807
+ }
1693
1808
  }
1694
1809
  const sensitivityAtEntry = contextResolutions;
1810
+ const scopeReadsAtEntry = scopeSensitivity;
1695
1811
  mapTypeDepth++;
1696
1812
  try {
1697
1813
  let mapped;
@@ -1717,6 +1833,17 @@ function mapTypeEntry(type, ctx) {
1717
1833
  contextResolutions++;
1718
1834
  }
1719
1835
  }
1836
+ // A PACKAGE DATA SHAPE the structural rules cannot map: `import type`
1837
+ // from a package whose implementation is not part of the compiled
1838
+ // module graph declares data the program itself builds, and a
1839
+ // declaration the compiled graph never loads cannot produce a value of
1840
+ // its own. A shape with no native mapping is then exactly the
1841
+ // checked-dynamic value — the same answer `unknown` gets — never the
1842
+ // package's story (there is no package value here to disagree with).
1843
+ if (mapped === null && packageTypeIsData(type, ctx)) {
1844
+ mapped = DYN;
1845
+ contextResolutions++;
1846
+ }
1720
1847
  // Localized failure: a type that failed at a committed slot maps to its
1721
1848
  // lenient form. It counts as a context resolution so neither it nor a
1722
1849
  // type containing it is memoized: the strict form may map elsewhere.
@@ -1737,10 +1864,25 @@ function mapTypeEntry(type, ctx) {
1737
1864
  if (mapped !== null &&
1738
1865
  memoKey !== null &&
1739
1866
  topLevel &&
1867
+ !bypassTypeMemo &&
1740
1868
  contextResolutions === sensitivityAtEntry &&
1741
1869
  ctx.erasingSignature === undefined &&
1742
1870
  (ctx.canMemoizeType?.() ?? true)) {
1743
- ctx.typeMemo?.set(memoKey, mapped);
1871
+ // Read the hook again rather than reusing the entry's memo: the write
1872
+ // condition rechecks the binding context, and a hook is what keeps a
1873
+ // context copy made inside a binding scope pointed at that scope.
1874
+ const liveMemo = ctx.typeMemoFor?.() ?? ctx.typeMemo;
1875
+ // A scope that changed mid-frame cannot own this answer. (It cannot
1876
+ // happen today; the identity check keeps it a proof rather than an
1877
+ // assumption.)
1878
+ if (liveMemo === contextMemo) {
1879
+ liveMemo?.set(memoKey, mapped);
1880
+ // An answer that read no scope state is every scope's answer, so it
1881
+ // also serves the shared memo — including the scopes entered later.
1882
+ const shared = ctx.typeMemoShared;
1883
+ if (shared !== undefined && shared !== liveMemo && scopeSensitivity === scopeReadsAtEntry)
1884
+ shared.set(memoKey, mapped);
1885
+ }
1744
1886
  }
1745
1887
  return mapped;
1746
1888
  }
@@ -1748,6 +1890,32 @@ function mapTypeEntry(type, ctx) {
1748
1890
  mapTypeDepth--;
1749
1891
  }
1750
1892
  }
1893
+ /** SCRIPTC_TYPE_MEMO_VERIFY: recomputes a shared memo entry in the scope
1894
+ * that just took it and fails loudly when the two answers disagree. The
1895
+ * recalculation runs with every memo bypassed and restores the mapping
1896
+ * counters it moves, so the observation leaves the mapping it observes
1897
+ * unchanged. */
1898
+ function verifySharedMapping(type, ctx, shared) {
1899
+ const resolutions = contextResolutions;
1900
+ const scopeReads = scopeSensitivity;
1901
+ bypassTypeMemo = true;
1902
+ let recomputed;
1903
+ try {
1904
+ recomputed = mapTypeEntry(type, ctx);
1905
+ }
1906
+ finally {
1907
+ bypassTypeMemo = false;
1908
+ contextResolutions = resolutions;
1909
+ scopeSensitivity = scopeReads;
1910
+ }
1911
+ const wanted = recomputed === null ? "<unmapped>" : typeKey(recomputed);
1912
+ verifiedSharedHits++;
1913
+ if (typeKey(shared) === wanted)
1914
+ return;
1915
+ throw new InternalCompilerError(`shared type memo entry does not match a fresh mapping: type ` +
1916
+ `${checkerTypeDescription(type, ctx)} answered ${typeKey(shared)} from the shared ` +
1917
+ `memo and ${wanted} when remapped in its scope`);
1918
+ }
1751
1919
  /** Local class types need the enclosing specialization's registered layout.
1752
1920
  * Static-block classes are sent through the same hook for an explicit fence. */
1753
1921
  function classExprNeedsContext(decl) {
@@ -1776,6 +1944,19 @@ function spreadsCheckedDynamic(symbol, ctx) {
1776
1944
  return decl.properties.nodes.some((prop) => ts.isSpreadAssignment(prop) &&
1777
1945
  mapType(ctx.checker.getTypeAtLocation(prop.expression), ctx)?.kind === "dyn");
1778
1946
  }
1947
+ /** The members a hand-written writable-pipe interface may name: the child
1948
+ * stdin surface a `Pipe { write(chunk: string): boolean; end(): void }`
1949
+ * declares (see the childWriter mapping in mapTypeInner). */
1950
+ const CHILD_WRITER_MEMBERS = new Set([
1951
+ "write",
1952
+ "end",
1953
+ "destroy",
1954
+ "writable",
1955
+ "on",
1956
+ "once",
1957
+ "off",
1958
+ "removeListener",
1959
+ ]);
1779
1960
  function mapTypeInner(type, ctx) {
1780
1961
  const { checker, unions, classNamer, resolveTypeParam } = ctx;
1781
1962
  // TypeScript's intrinsic globalThis symbol has no declaration. A stored
@@ -2201,30 +2382,13 @@ function mapTypeInner(type, ctx) {
2201
2382
  // such a type is one the program built itself (`import type` from a
2202
2383
  // types-only package), so it maps structurally like a local declaration.
2203
2384
  // Values the package itself would produce stay refused at their import.
2204
- const packageOnly = (sym) => {
2205
- const decls = sym ? sym.declarations : undefined;
2206
- return decls &&
2207
- decls.length > 0 &&
2208
- decls.every((d) => {
2209
- const sf = ts.getSourceFileOfNode(d);
2210
- return sf.isDeclarationFile && !ctx.isStdlibFile(sf) && !ctx.isExternalTypeFile(sf);
2211
- })
2212
- ? decls
2213
- : null;
2214
- };
2215
- const pureTypeShape = (decls) => decls === null ||
2216
- decls.every((d) => packageTypeFile(ts.getSourceFileOfNode(d), ctx) &&
2217
- (ts.isInterfaceDeclaration(d) ||
2218
- ts.isTypeAliasDeclaration(d) ||
2219
- ts.isTypeLiteralNode(d) ||
2220
- ts.isMappedTypeNode(d) ||
2221
- isDeclaredDataClass(d) ||
2222
- (decls.some(isDeclaredDataClass) && isTypeOnlyNamespace(d))));
2223
- const aliasDecls = packageOnly(widened.getAliasSymbol());
2224
- const ownDecls = packageOnly(widened.getSymbol());
2225
- if ((aliasDecls !== null || (widened.getAliasSymbol() === undefined && ownDecls !== null)) &&
2226
- !(pureTypeShape(aliasDecls) && pureTypeShape(ownDecls))) {
2227
- return null;
2385
+ {
2386
+ const aliasDecls = packageDeclarations(widened.getAliasSymbol(), ctx);
2387
+ const ownDecls = packageDeclarations(widened.getSymbol(), ctx);
2388
+ if ((aliasDecls !== null || (widened.getAliasSymbol() === undefined && ownDecls !== null)) &&
2389
+ !(purePackageDeclarations(aliasDecls, ctx) && purePackageDeclarations(ownDecls, ctx))) {
2390
+ return null;
2391
+ }
2228
2392
  }
2229
2393
  // Module namespaces were claimed above when they name compiled source
2230
2394
  // modules or supported builtins. Declaration-only namespaces remain refused.
@@ -2614,15 +2778,24 @@ function mapTypeInner(type, ctx) {
2614
2778
  // outside stays unmapped — callers report the component fence (SC2009)
2615
2779
  // naming the offending half, as does the `new Map` lowering per site.
2616
2780
  const psym = widened.getSymbol();
2617
- const isStdlibInterface = (name) => psym !== undefined &&
2618
- ts.symbolName(psym) === name &&
2619
- psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)));
2781
+ // The symbol's name and its standard-library declarations, asked once per
2782
+ // type (provenanceOf memoizes the answer per symbol). No symbol is named
2783
+ // "", so the absent symbol's placeholder names nothing.
2784
+ const psymName = psym === undefined ? "" : ts.symbolName(psym);
2785
+ const provenance = psym === undefined ? null : provenanceOf(psym, ctx);
2786
+ const isStdlibInterface = (name) => provenance !== null && name === psymName && provenance.stdlibInterface;
2787
+ // The async iteration protocols a `for await` source is annotated with
2788
+ // (and the older spelling of an async generator's iterator object). Node's
2789
+ // typings declare an interface named AsyncIterator too — the native handle
2790
+ // timers/promises.setInterval answers, which that builtin's lowering
2791
+ // builds — so only the ES lib's declarations take the protocol mapping.
2792
+ const isLibAsyncInterface = (name) => provenance !== null && name === psymName && provenance.libInterface;
2793
+ const isAsyncIterationProtocol = () => isLibAsyncInterface("AsyncIterable") ||
2794
+ isLibAsyncInterface("AsyncIterator") ||
2795
+ isLibAsyncInterface("AsyncIterableIterator");
2620
2796
  // The timer handles: an interface in the fallback and in @types/node 22+,
2621
2797
  // a class (`class Timeout implements Timer`) in @types/node 20 and older.
2622
- const isStdlibTimerHandle = (name) => psym !== undefined &&
2623
- ts.symbolName(psym) === name &&
2624
- psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2625
- ctx.isStdlibFile(ts.getSourceFileOfNode(d)));
2798
+ const isStdlibTimerHandle = (name) => provenance !== null && name === psymName && provenance.stdlibClass;
2626
2799
  // The builtin Error classes: references to the lib's Error interfaces map to the runtime-provided class
2627
2800
  // hierarchy (provenance, not the name — a user's own `class Error`
2628
2801
  // resolved through the class-instance branch above, and a user
@@ -2636,7 +2809,7 @@ function mapTypeInner(type, ctx) {
2636
2809
  // node:assert's AssertionError is declared as a class (in the shipped
2637
2810
  // fallback and in @types/node), not as a lib interface.
2638
2811
  if (psym !== undefined &&
2639
- ts.symbolName(psym) === "AssertionError" &&
2812
+ psymName === "AssertionError" &&
2640
2813
  psym.declarations.some((d) => ts.isClassDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d))))
2641
2814
  return { kind: "object", className: "%AssertionError" };
2642
2815
  // The lib's `Object` interface is a TOP type: tsc admits every
@@ -2653,11 +2826,11 @@ function mapTypeInner(type, ctx) {
2653
2826
  // module lowering before generic number operations can observe the
2654
2827
  // representation. The node:module class's merged instance interface is
2655
2828
  // included, while unrelated user interfaces named Module stay structural.
2656
- if (((psym !== undefined && ts.symbolName(psym) === "ScriptcModule") ||
2657
- (psym !== undefined && ts.symbolName(psym) === "Module")) &&
2829
+ if (((psym !== undefined && psymName === "ScriptcModule") ||
2830
+ (psym !== undefined && psymName === "Module")) &&
2658
2831
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2659
2832
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2660
- (ts.symbolName(psym) === "ScriptcModule" ||
2833
+ (psymName === "ScriptcModule" ||
2661
2834
  isDeclaredInAmbientNamespace(d, "NodeJS") ||
2662
2835
  isDeclaredInAmbientModule(d, "module")))) {
2663
2836
  return F64;
@@ -2670,7 +2843,7 @@ function mapTypeInner(type, ctx) {
2670
2843
  // NodeJS.EventEmitter interface (the structural surface net.Socket
2671
2844
  // et al. extend) is the same runtime value. Provenance-checked.
2672
2845
  if (psym !== undefined &&
2673
- ts.symbolName(psym) === "EventEmitter" &&
2846
+ psymName === "EventEmitter" &&
2674
2847
  psym.declarations.some((d) => (ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
2675
2848
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2676
2849
  (isDeclaredInAmbientModule(d, "events") || isDeclaredInAmbientNamespace(d, "NodeJS")))) {
@@ -2681,7 +2854,7 @@ function mapTypeInner(type, ctx) {
2681
2854
  // precedent). The NAME is generic, so the provenance check adds the
2682
2855
  // enclosing ambient module, like net.Server.
2683
2856
  if (psym !== undefined &&
2684
- ts.symbolName(psym) === "Interface" &&
2857
+ psymName === "Interface" &&
2685
2858
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2686
2859
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2687
2860
  (isDeclaredInAmbientModule(d, "readline") ||
@@ -2692,7 +2865,7 @@ function mapTypeInner(type, ctx) {
2692
2865
  // it keeps Node's own shape (an undefined name, the escape sequences'
2693
2866
  // code member).
2694
2867
  if (psym !== undefined &&
2695
- ts.symbolName(psym) === "Key" &&
2868
+ psymName === "Key" &&
2696
2869
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
2697
2870
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2698
2871
  (isDeclaredInAmbientModule(d, "readline") ||
@@ -2701,7 +2874,7 @@ function mapTypeInner(type, ctx) {
2701
2874
  }
2702
2875
  // readline/promises.Readline: an f64 handle the same way.
2703
2876
  if (psym !== undefined &&
2704
- ts.symbolName(psym) === "Readline" &&
2877
+ psymName === "Readline" &&
2705
2878
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2706
2879
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2707
2880
  isDeclaredInAmbientModule(d, "readline/promises"))) {
@@ -2714,7 +2887,7 @@ function mapTypeInner(type, ctx) {
2714
2887
  // plus the ambient module suffices for both the fallback declarations
2715
2888
  // and @types/node's class Channel<StoreType, ContextType>.
2716
2889
  if (psym !== undefined &&
2717
- ts.symbolName(psym) === "Channel" &&
2890
+ psymName === "Channel" &&
2718
2891
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2719
2892
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2720
2893
  isDeclaredInAmbientModule(d, "diagnostics_channel"))) {
@@ -2724,7 +2897,7 @@ function mapTypeInner(type, ctx) {
2724
2897
  // the runtime's store id space (the Channel story — stores are
2725
2898
  // process-lived; contexts ride the fiber machinery).
2726
2899
  if (psym !== undefined &&
2727
- ts.symbolName(psym) === "AsyncLocalStorage" &&
2900
+ psymName === "AsyncLocalStorage" &&
2728
2901
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2729
2902
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2730
2903
  isDeclaredInAmbientModule(d, "async_hooks"))) {
@@ -2733,7 +2906,7 @@ function mapTypeInner(type, ctx) {
2733
2906
  // diagnostics_channel.TracingChannel: the same f64-handle story over the
2734
2907
  // runtime's tracing registry (five event channels per entry).
2735
2908
  if (psym !== undefined &&
2736
- ts.symbolName(psym) === "TracingChannel" &&
2909
+ psymName === "TracingChannel" &&
2737
2910
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2738
2911
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2739
2912
  isDeclaredInAmbientModule(d, "diagnostics_channel"))) {
@@ -2766,15 +2939,15 @@ function mapTypeInner(type, ctx) {
2766
2939
  };
2767
2940
  // WHATWG codec instances have ordinary reference identity and ownership.
2768
2941
  // Their private encoding slot is omitted from enumeration and JSON.
2769
- if (((psym !== undefined && ts.symbolName(psym) === "TextEncoder") ||
2770
- (psym !== undefined && ts.symbolName(psym) === "TextDecoder")) &&
2942
+ if (((psym !== undefined && psymName === "TextEncoder") ||
2943
+ (psym !== undefined && psymName === "TextDecoder")) &&
2771
2944
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2772
2945
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2773
2946
  return {
2774
2947
  kind: "record",
2775
2948
  shapeId: ctx.shapes.intern([
2776
- { name: `%${ts.symbolName(psym)}`, type: F64 },
2777
- ...(ts.symbolName(psym) === "TextDecoder"
2949
+ { name: `%${psymName}`, type: F64 },
2950
+ ...(psymName === "TextDecoder"
2778
2951
  ? [
2779
2952
  { name: "%fatal", type: BOOL },
2780
2953
  { name: "%ignoreBOM", type: BOOL },
@@ -2792,7 +2965,7 @@ function mapTypeInner(type, ctx) {
2792
2965
  // special-cased in lowerNew / lowerStringDecoderMethodCall, so the
2793
2966
  // record shape never surfaces.
2794
2967
  if (psym !== undefined &&
2795
- ts.symbolName(psym) === "StringDecoder" &&
2968
+ psymName === "StringDecoder" &&
2796
2969
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2797
2970
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2798
2971
  return {
@@ -2861,7 +3034,7 @@ function mapTypeInner(type, ctx) {
2861
3034
  // `typeof inspect`): the runtime's inspect function, called through the
2862
3035
  // checked-dynamic boundary.
2863
3036
  if (psym !== undefined &&
2864
- ts.symbolName(psym) === "inspect" &&
3037
+ psymName === "inspect" &&
2865
3038
  psym.declarations.some((d) => ts.isFunctionDeclaration(d) &&
2866
3039
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2867
3040
  isDeclaredInAmbientModule(d, "util")))
@@ -2882,7 +3055,7 @@ function mapTypeInner(type, ctx) {
2882
3055
  // option record whose members include functions, agents and signals.
2883
3056
  // Values ride checked-dynamic storage, like SpawnOptions.
2884
3057
  if (psym !== undefined &&
2885
- ts.symbolName(psym) === "RequestOptions" &&
3058
+ psymName === "RequestOptions" &&
2886
3059
  psym.declarations.some((d) => {
2887
3060
  if (!ts.isInterfaceDeclaration(d) || !ctx.isStdlibFile(ts.getSourceFileOfNode(d)))
2888
3061
  return false;
@@ -2916,8 +3089,7 @@ function mapTypeInner(type, ctx) {
2916
3089
  }
2917
3090
  }
2918
3091
  if (psym &&
2919
- (ts.symbolName(psym) === "ReadableStreamReadValueResult" ||
2920
- ts.symbolName(psym) === "ReadableStreamReadDoneResult") &&
3092
+ (psymName === "ReadableStreamReadValueResult" || psymName === "ReadableStreamReadDoneResult") &&
2921
3093
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2922
3094
  const elemTs = checker.getTypeArguments(widened)[0];
2923
3095
  const elem = elemTs && elemTs.flags & ts.TypeFlags.Any ? DYN : elemTs ? mapType(elemTs, ctx) : null;
@@ -2928,10 +3100,10 @@ function mapTypeInner(type, ctx) {
2928
3100
  // node:net's SocketAddress and BlockList (scr_net.c) and node:util's
2929
3101
  // MIMEType and MIMEParams (scr_mime.c): native handles whose getters and
2930
3102
  // methods dispatch through the handle.
2931
- if (((psym !== undefined && ts.symbolName(psym) === "SocketAddress") ||
2932
- (psym !== undefined && ts.symbolName(psym) === "BlockList") ||
2933
- (psym !== undefined && ts.symbolName(psym) === "MIMEType") ||
2934
- (psym !== undefined && ts.symbolName(psym) === "MIMEParams")) &&
3103
+ if (((psym !== undefined && psymName === "SocketAddress") ||
3104
+ (psym !== undefined && psymName === "BlockList") ||
3105
+ (psym !== undefined && psymName === "MIMEType") ||
3106
+ (psym !== undefined && psymName === "MIMEParams")) &&
2935
3107
  psym.declarations.some((d) => (ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
2936
3108
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2937
3109
  return DYN;
@@ -2940,7 +3112,7 @@ function mapTypeInner(type, ctx) {
2940
3112
  // (scr_util_timing.c): native functions with their own members and
2941
3113
  // getters.
2942
3114
  if (psym !== undefined &&
2943
- (ts.symbolName(psym) === "DebouncedFunction" || ts.symbolName(psym) === "ThrottledFunction") &&
3115
+ (psymName === "DebouncedFunction" || psymName === "ThrottledFunction") &&
2944
3116
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2945
3117
  return DYN;
2946
3118
  }
@@ -2949,7 +3121,7 @@ function mapTypeInner(type, ctx) {
2949
3121
  // the algorithm dictionaries the methods take and keys report are plain
2950
3122
  // checked-dynamic objects.
2951
3123
  if (psym &&
2952
- WEBCRYPTO_DYN_TYPES.has(ts.symbolName(psym)) &&
3124
+ WEBCRYPTO_DYN_TYPES.has(psymName) &&
2953
3125
  psym.declarations.some((d) => (ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
2954
3126
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2955
3127
  return DYN;
@@ -2958,8 +3130,8 @@ function mapTypeInner(type, ctx) {
2958
3130
  // public keys (scr_pki.c) are native handles whose getters and methods
2959
3131
  // dispatch through the handle. The JsonWebKey that export() returns is a
2960
3132
  // plain checked-dynamic object.
2961
- if (((psym !== undefined && ts.symbolName(psym) === "KeyObject") ||
2962
- (psym !== undefined && ts.symbolName(psym) === "JsonWebKey")) &&
3133
+ if (((psym !== undefined && psymName === "KeyObject") ||
3134
+ (psym !== undefined && psymName === "JsonWebKey")) &&
2963
3135
  psym.declarations.some((d) => (ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
2964
3136
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
2965
3137
  return DYN;
@@ -2968,7 +3140,7 @@ function mapTypeInner(type, ctx) {
2968
3140
  // objects, so a value asserted to one (`opts as
2969
3141
  // crypto.AsymmetricKeyExportOptions<"pem">`) reaches the call unchanged.
2970
3142
  if (psym !== undefined &&
2971
- CRYPTO_KEY_OPTION_DYN_TYPES.has(ts.symbolName(psym)) &&
3143
+ CRYPTO_KEY_OPTION_DYN_TYPES.has(psymName) &&
2972
3144
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
2973
3145
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2974
3146
  isDeclaredInAmbientModule(d, "crypto"))) {
@@ -2977,15 +3149,15 @@ function mapTypeInner(type, ctx) {
2977
3149
  // node:crypto's Sign and Verify (createSign/createVerify): native
2978
3150
  // handles over the digest state (scr_pki.c).
2979
3151
  if (psym !== undefined &&
2980
- (ts.symbolName(psym) === "Sign" || ts.symbolName(psym) === "Verify") &&
3152
+ (psymName === "Sign" || psymName === "Verify") &&
2981
3153
  psym.declarations.some((d) => ts.isClassDeclaration(d) &&
2982
3154
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
2983
3155
  isDeclaredInAmbientModule(d, "crypto"))) {
2984
3156
  return DYN;
2985
3157
  }
2986
3158
  if (psym &&
2987
- FETCH_AMBIENT_TYPES.includes(ts.symbolName(psym)) &&
2988
- !((ts.symbolName(psym) === "ReadableStream" || ts.symbolName(psym) === "WritableStream") &&
3159
+ FETCH_AMBIENT_TYPES.includes(psymName) &&
3160
+ !((psymName === "ReadableStream" || psymName === "WritableStream") &&
2989
3161
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && isDeclaredInAmbientNamespace(d, "NodeJS"))) &&
2990
3162
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
2991
3163
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
@@ -2998,10 +3170,10 @@ function mapTypeInner(type, ctx) {
2998
3170
  // AsyncDisposable are checked objects carrying their Symbol.dispose or
2999
3171
  // Symbol.asyncDispose method. A DisposableStack is a native handle whose
3000
3172
  // methods are function values of its checked-dynamic view.
3001
- if (((psym !== undefined && ts.symbolName(psym) === "Console") ||
3002
- (psym !== undefined && ts.symbolName(psym) === "Disposable") ||
3003
- (psym !== undefined && ts.symbolName(psym) === "AsyncDisposable") ||
3004
- (psym !== undefined && ts.symbolName(psym) === "DisposableStack")) &&
3173
+ if (((psym !== undefined && psymName === "Console") ||
3174
+ (psym !== undefined && psymName === "Disposable") ||
3175
+ (psym !== undefined && psymName === "AsyncDisposable") ||
3176
+ (psym !== undefined && psymName === "DisposableStack")) &&
3005
3177
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3006
3178
  return DYN;
3007
3179
  }
@@ -3009,14 +3181,14 @@ function mapTypeInner(type, ctx) {
3009
3181
  // interfaces over them) are native handles carried by the checked-dynamic
3010
3182
  // representation; lowerCipherMethodCall dispatches their methods.
3011
3183
  if (psym !== undefined &&
3012
- CIPHER_TYPE_NAMES.has(ts.symbolName(psym)) &&
3184
+ CIPHER_TYPE_NAMES.has(psymName) &&
3013
3185
  psym.declarations.some((d) => ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3014
3186
  return DYN;
3015
3187
  }
3016
3188
  // node:crypto ECDH values are native handles carried by the
3017
3189
  // checked-dynamic representation; lowerEcdhCall dispatches their methods.
3018
3190
  if (psym !== undefined &&
3019
- ts.symbolName(psym) === "ECDH" &&
3191
+ psymName === "ECDH" &&
3020
3192
  psym.declarations.some((d) => ts.isClassDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3021
3193
  return DYN;
3022
3194
  }
@@ -3169,7 +3341,7 @@ function mapTypeInner(type, ctx) {
3169
3341
  // fallback and by @types/node (whose NonSharedBuffer alias resolves to
3170
3342
  // the same symbol); provenance-checked like URL.
3171
3343
  if (psym !== undefined &&
3172
- ts.symbolName(psym) === "Buffer" &&
3344
+ psymName === "Buffer" &&
3173
3345
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3174
3346
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3175
3347
  return bytesOf("u8");
@@ -3180,7 +3352,7 @@ function mapTypeInner(type, ctx) {
3180
3352
  // instance type). Provenance, not the name: a user's own URL maps as a
3181
3353
  // record/class like any other.
3182
3354
  if (psym !== undefined &&
3183
- ts.symbolName(psym) === "URL" &&
3355
+ psymName === "URL" &&
3184
3356
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3185
3357
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3186
3358
  return { kind: "url" };
@@ -3189,7 +3361,7 @@ function mapTypeInner(type, ctx) {
3189
3361
  // interface by the shipped fallback and by @types/node (plus `class
3190
3362
  // URLSearchParams` in the "url" module). Provenance-checked like URL.
3191
3363
  if (psym !== undefined &&
3192
- ts.symbolName(psym) === "URLSearchParams" &&
3364
+ psymName === "URLSearchParams" &&
3193
3365
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3194
3366
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3195
3367
  return { kind: "searchParams" };
@@ -3197,7 +3369,7 @@ function mapTypeInner(type, ctx) {
3197
3369
  // fs.Stats: @types/node's `class Stats` (module "fs") or the fallback
3198
3370
  // declarations' interface. Provenance-checked like URL.
3199
3371
  if (psym !== undefined &&
3200
- ts.symbolName(psym) === "Stats" &&
3372
+ psymName === "Stats" &&
3201
3373
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3202
3374
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3203
3375
  return { kind: "stats" };
@@ -3207,16 +3379,16 @@ function mapTypeInner(type, ctx) {
3207
3379
  // `class BigIntStats` in "fs"; the fallback declarations keep the class
3208
3380
  // shape too. Provenance-checked like Stats.
3209
3381
  if (psym !== undefined &&
3210
- ts.symbolName(psym) === "BigIntStats" &&
3382
+ psymName === "BigIntStats" &&
3211
3383
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3212
3384
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3213
3385
  return { kind: "bigintStats" };
3214
3386
  }
3215
3387
  // Capacity snapshots and options keep their live object representation
3216
3388
  // across numeric/BigInt overloads, runtime options, and callbacks.
3217
- if (((psym !== undefined && ts.symbolName(psym) === "StatsFs") ||
3218
- (psym !== undefined && ts.symbolName(psym) === "BigIntStatsFs") ||
3219
- (psym !== undefined && ts.symbolName(psym) === "StatFsOptions")) &&
3389
+ if (((psym !== undefined && psymName === "StatsFs") ||
3390
+ (psym !== undefined && psymName === "BigIntStatsFs") ||
3391
+ (psym !== undefined && psymName === "StatFsOptions")) &&
3220
3392
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3221
3393
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3222
3394
  isDeclaredInAmbientModule(d, "fs")))
@@ -3227,7 +3399,7 @@ function mapTypeInner(type, ctx) {
3227
3399
  // distinguishes it from user interfaces with the same name; both the
3228
3400
  // fallback and @types/node declare it in "fs/promises".
3229
3401
  if (psym !== undefined &&
3230
- ts.symbolName(psym) === "FileHandle" &&
3402
+ psymName === "FileHandle" &&
3231
3403
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3232
3404
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3233
3405
  isDeclaredInAmbientModule(d, "fs/promises"))) {
@@ -3236,7 +3408,7 @@ function mapTypeInner(type, ctx) {
3236
3408
  // fs.Dir: an open directory stream, declared in "fs" by both the
3237
3409
  // fallback and @types/node.
3238
3410
  if (psym !== undefined &&
3239
- ts.symbolName(psym) === "Dir" &&
3411
+ psymName === "Dir" &&
3240
3412
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3241
3413
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3242
3414
  isDeclaredInAmbientModule(d, "fs"))) {
@@ -3247,7 +3419,7 @@ function mapTypeInner(type, ctx) {
3247
3419
  // reads work either way) or the fallback declarations' plain interface.
3248
3420
  // Provenance-checked like Stats.
3249
3421
  if (psym !== undefined &&
3250
- ts.symbolName(psym) === "SpawnSyncReturns" &&
3422
+ psymName === "SpawnSyncReturns" &&
3251
3423
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3252
3424
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3253
3425
  return { kind: "spawnRes" };
@@ -3256,9 +3428,9 @@ function mapTypeInner(type, ctx) {
3256
3428
  // interfaces: all carry the same runtime child handle; the generic
3257
3429
  // refinements only tell the checker which stdio properties are null.
3258
3430
  if (psym !== undefined &&
3259
- (ts.symbolName(psym) === "ChildProcess" ||
3260
- ts.symbolName(psym) === "ChildProcessWithoutNullStreams" ||
3261
- ts.symbolName(psym) === "ChildProcessByStdio") &&
3431
+ (psymName === "ChildProcess" ||
3432
+ psymName === "ChildProcessWithoutNullStreams" ||
3433
+ psymName === "ChildProcessByStdio") &&
3262
3434
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3263
3435
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3264
3436
  isDeclaredInAmbientModule(d, "child_process"))) {
@@ -3271,9 +3443,9 @@ function mapTypeInner(type, ctx) {
3271
3443
  // declare these inside `declare module "net"` — a declaration outside
3272
3444
  // that module (http's Server) stays unmapped and fences at its use
3273
3445
  // site.
3274
- if (((psym !== undefined && ts.symbolName(psym) === "Server") ||
3275
- (psym !== undefined && ts.symbolName(psym) === "Socket") ||
3276
- (psym !== undefined && ts.symbolName(psym) === "TLSSocket")) &&
3446
+ if (((psym !== undefined && psymName === "Server") ||
3447
+ (psym !== undefined && psymName === "Socket") ||
3448
+ (psym !== undefined && psymName === "TLSSocket")) &&
3277
3449
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3278
3450
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3279
3451
  (isDeclaredInAmbientModule(d, "net") ||
@@ -3282,12 +3454,12 @@ function mapTypeInner(type, ctx) {
3282
3454
  // (listen/close/address/'error'), same handle kind. tls.TLSSocket
3283
3455
  // extends net.Socket the same way: post-handshake it IS a net
3284
3456
  // socket to every lowered member.
3285
- (ts.symbolName(psym) === "Server" &&
3457
+ (psymName === "Server" &&
3286
3458
  (isDeclaredInAmbientModule(d, "http") ||
3287
3459
  isDeclaredInAmbientModule(d, "tls") ||
3288
3460
  isDeclaredInAmbientModule(d, "https"))) ||
3289
- (ts.symbolName(psym) === "TLSSocket" && isDeclaredInAmbientModule(d, "tls"))))) {
3290
- return ts.symbolName(psym) === "Server" ? { kind: "netServer" } : { kind: "netSocket" };
3461
+ (psymName === "TLSSocket" && isDeclaredInAmbientModule(d, "tls"))))) {
3462
+ return psymName === "Server" ? { kind: "netServer" } : { kind: "netSocket" };
3291
3463
  }
3292
3464
  // tls.SecureContext: the opaque parsed-cert/key handle SNI callbacks
3293
3465
  // answer with (tls.createSecureContext({ cert, key }) mints it; the TLS
@@ -3295,7 +3467,7 @@ function mapTypeInner(type, ctx) {
3295
3467
  // @types/node declares `interface SecureContext` inside `declare module
3296
3468
  // "tls"`, and the shipped fallback mirrors it.
3297
3469
  if (psym !== undefined &&
3298
- ts.symbolName(psym) === "SecureContext" &&
3470
+ psymName === "SecureContext" &&
3299
3471
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3300
3472
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3301
3473
  isDeclaredInAmbientModule(d, "tls"))) {
@@ -3304,7 +3476,7 @@ function mapTypeInner(type, ctx) {
3304
3476
  // Scrypt's runtime options retain property accessors and aliases. Use
3305
3477
  // checked values so presence probes and repeated getter reads match Node.
3306
3478
  if (psym !== undefined &&
3307
- ts.symbolName(psym) === "ScryptOptions" &&
3479
+ psymName === "ScryptOptions" &&
3308
3480
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3309
3481
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3310
3482
  isDeclaredInAmbientModule(d, "crypto")))
@@ -3312,19 +3484,18 @@ function mapTypeInner(type, ctx) {
3312
3484
  // crypto.Hash / crypto.Hmac: native incremental digest handles. Keep
3313
3485
  // provenance module-qualified so user classes with these common names
3314
3486
  // retain their ordinary structural/class representation.
3315
- if (((psym !== undefined && ts.symbolName(psym) === "Hash") ||
3316
- (psym !== undefined && ts.symbolName(psym) === "Hmac")) &&
3487
+ if (((psym !== undefined && psymName === "Hash") || (psym !== undefined && psymName === "Hmac")) &&
3317
3488
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3318
3489
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3319
3490
  isDeclaredInAmbientModule(d, "crypto"))) {
3320
- return ts.symbolName(psym) === "Hash" ? CRYPTOHASH_T : CRYPTOHMAC_T;
3491
+ return psymName === "Hash" ? CRYPTOHASH_T : CRYPTOHMAC_T;
3321
3492
  }
3322
3493
  // fs.FSWatcher: the fs.watch handle (scr_watch.c). Module-checked like
3323
3494
  // net.Server — @types/node declares `interface FSWatcher extends
3324
3495
  // EventEmitter` inside `declare module "fs"`, and the shipped fallback
3325
3496
  // mirrors it.
3326
3497
  if (psym !== undefined &&
3327
- ts.symbolName(psym) === "FSWatcher" &&
3498
+ psymName === "FSWatcher" &&
3328
3499
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3329
3500
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3330
3501
  isDeclaredInAmbientModule(d, "fs"))) {
@@ -3366,7 +3537,7 @@ function mapTypeInner(type, ctx) {
3366
3537
  return DYN;
3367
3538
  }
3368
3539
  const nodeWritableInterface = psym !== undefined &&
3369
- ts.symbolName(psym) === "WritableStream" &&
3540
+ psymName === "WritableStream" &&
3370
3541
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3371
3542
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3372
3543
  isDeclaredInAmbientNamespace(d, "NodeJS"));
@@ -3374,7 +3545,7 @@ function mapTypeInner(type, ctx) {
3374
3545
  return ctx.dynNodeStreams === true ? DYN : { kind: "object", className: "%Writable" };
3375
3546
  }
3376
3547
  if ((psym !== undefined &&
3377
- ts.symbolName(psym) === "WriteStream" &&
3548
+ psymName === "WriteStream" &&
3378
3549
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3379
3550
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3380
3551
  (isDeclaredInAmbientModule(d, "tty") ||
@@ -3387,13 +3558,13 @@ function mapTypeInner(type, ctx) {
3387
3558
  // stream.Writable. As with stream.Readable below, unsupported producers
3388
3559
  // of the broad @types class fence where they are constructed.
3389
3560
  if ((psym !== undefined &&
3390
- ts.symbolName(psym) === "ChildStdin" &&
3561
+ psymName === "ChildStdin" &&
3391
3562
  ctx.generalNodeStreams !== true &&
3392
3563
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3393
3564
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3394
3565
  isDeclaredInAmbientModule(d, "child_process"))) ||
3395
3566
  (psym !== undefined &&
3396
- ts.symbolName(psym) === "Writable" &&
3567
+ psymName === "Writable" &&
3397
3568
  ctx.generalNodeStreams !== true &&
3398
3569
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3399
3570
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
@@ -3405,7 +3576,7 @@ function mapTypeInner(type, ctx) {
3405
3576
  // ChildStdin is the runtime Writable too (child.stdioStream bridges it).
3406
3577
  if (ctx.generalNodeStreams === true &&
3407
3578
  psym !== undefined &&
3408
- ts.symbolName(psym) === "ChildStdin" &&
3579
+ psymName === "ChildStdin" &&
3409
3580
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3410
3581
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3411
3582
  isDeclaredInAmbientModule(d, "child_process"))) {
@@ -3423,7 +3594,7 @@ function mapTypeInner(type, ctx) {
3423
3594
  // Writable join them under the general representation.
3424
3595
  for (const [irName, rec] of RUNTIME_STREAM_CLASSES) {
3425
3596
  if (psym !== undefined &&
3426
- ts.symbolName(psym) === rec.lib &&
3597
+ psymName === rec.lib &&
3427
3598
  psym.declarations.some((d) => ts.isClassDeclaration(d) &&
3428
3599
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3429
3600
  (!isNodeTypesPath(ts.getSourceFileOfNode(d).fileName) ||
@@ -3436,7 +3607,7 @@ function mapTypeInner(type, ctx) {
3436
3607
  // node:zlib's stream classes (the shipped fallback declarations and
3437
3608
  // @types/node's): their instances are runtime Transform streams.
3438
3609
  if (psym !== undefined &&
3439
- ZLIB_STREAM_MODES.has(ts.symbolName(psym)) &&
3610
+ ZLIB_STREAM_MODES.has(psymName) &&
3440
3611
  psym.declarations.some((d) => (ts.isClassDeclaration(d) ||
3441
3612
  (ts.isInterfaceDeclaration(d) && isNodeTypesPath(ts.getSourceFileOfNode(d).fileName))) &&
3442
3613
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
@@ -3446,32 +3617,38 @@ function mapTypeInner(type, ctx) {
3446
3617
  // fs.ReadStream / fs.WriteStream (the shipped fallback declarations and
3447
3618
  // @types/node's): their instances are runtime Readable / Writable
3448
3619
  // streams (scr_fs_stream.c).
3449
- if (((psym !== undefined && ts.symbolName(psym) === "ReadStream") ||
3450
- (psym !== undefined && ts.symbolName(psym) === "WriteStream")) &&
3620
+ if (((psym !== undefined && psymName === "ReadStream") ||
3621
+ (psym !== undefined && psymName === "WriteStream")) &&
3451
3622
  psym.declarations.some((d) => ts.isClassDeclaration(d) &&
3452
3623
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3453
3624
  isDeclaredInAmbientModule(d, "fs"))) {
3454
3625
  return {
3455
3626
  kind: "object",
3456
- className: ts.symbolName(psym) === "ReadStream" ? "%Readable" : "%Writable",
3627
+ className: psymName === "ReadStream" ? "%Readable" : "%Writable",
3457
3628
  };
3458
3629
  }
3459
3630
  if ((psym !== undefined &&
3460
- ts.symbolName(psym) === "Readable" &&
3631
+ psymName === "Readable" &&
3461
3632
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3462
3633
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3463
3634
  isDeclaredInAmbientModule(d, "stream"))) ||
3464
3635
  (psym !== undefined &&
3465
- ts.symbolName(psym) === "ReadableStream" &&
3636
+ psymName === "ReadableStream" &&
3637
+ psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3638
+ ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3639
+ isDeclaredInAmbientNamespace(d, "NodeJS"))) ||
3640
+ (psym !== undefined &&
3641
+ psymName === "ChildStdout" &&
3466
3642
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3467
3643
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3468
- isDeclaredInAmbientNamespace(d, "NodeJS")))) {
3644
+ isDeclaredInAmbientModule(d, "child_process")))) {
3469
3645
  // The general representation: the runtime Readable, which child
3470
3646
  // stdio reads produce through the child stream bridge. With
3471
3647
  // checked-dynamic stream slots, NodeJS.ReadableStream holds any
3472
3648
  // stream value (dyn-streams.ts); stream.Readable keeps the class.
3473
3649
  if (ctx.generalNodeStreams === true) {
3474
- if (ctx.dynNodeStreams === true && ts.symbolName(psym) === "ReadableStream")
3650
+ if (ctx.dynNodeStreams === true &&
3651
+ (psymName === "ReadableStream" || psymName === "ChildStdout"))
3475
3652
  return DYN;
3476
3653
  return { kind: "object", className: "%Readable" };
3477
3654
  }
@@ -3482,7 +3659,7 @@ function mapTypeInner(type, ctx) {
3482
3659
  // EventEmitter` and the fallback declarations' interface both live
3483
3660
  // inside `declare module "dgram"`.
3484
3661
  if (psym !== undefined &&
3485
- ts.symbolName(psym) === "Socket" &&
3662
+ psymName === "Socket" &&
3486
3663
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3487
3664
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3488
3665
  isDeclaredInAmbientModule(d, "dgram"))) {
@@ -3494,8 +3671,8 @@ function mapTypeInner(type, ctx) {
3494
3671
  // classes and the fallback declarations' interfaces all live inside
3495
3672
  // `declare module "node:test"` (isDeclaredInAmbientModule answers for
3496
3673
  // both spellings).
3497
- if (((psym !== undefined && ts.symbolName(psym) === "TestContext") ||
3498
- (psym !== undefined && ts.symbolName(psym) === "SuiteContext")) &&
3674
+ if (((psym !== undefined && psymName === "TestContext") ||
3675
+ (psym !== undefined && psymName === "SuiteContext")) &&
3499
3676
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3500
3677
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3501
3678
  isDeclaredInAmbientModule(d, "test"))) {
@@ -3504,8 +3681,8 @@ function mapTypeInner(type, ctx) {
3504
3681
  // node:test's MockFunctionContext<F> and MockFunctionCall<F>: compiler
3505
3682
  // records built from F (mock-shapes.ts). Mock<F> then maps as the hybrid
3506
3683
  // { %call: F, mock } record through mapHybridCallableIntersection.
3507
- if (((psym !== undefined && ts.symbolName(psym) === "MockFunctionContext") ||
3508
- (psym !== undefined && ts.symbolName(psym) === "MockFunctionCall")) &&
3684
+ if (((psym !== undefined && psymName === "MockFunctionContext") ||
3685
+ (psym !== undefined && psymName === "MockFunctionCall")) &&
3509
3686
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3510
3687
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3511
3688
  isDeclaredInAmbientModule(d, "test"))) {
@@ -3513,7 +3690,7 @@ function mapTypeInner(type, ctx) {
3513
3690
  const fn = fnTs ? mapType(fnTs, ctx) : null;
3514
3691
  if (!fn || fn.kind !== "func")
3515
3692
  return null;
3516
- return ts.symbolName(psym) === "MockFunctionContext"
3693
+ return psymName === "MockFunctionContext"
3517
3694
  ? mockContextType(fn, ctx)
3518
3695
  : mockCallRecordType(fn, ctx);
3519
3696
  }
@@ -3523,7 +3700,7 @@ function mapTypeInner(type, ctx) {
3523
3700
  // above; optional metadata uses the same checked property view.
3524
3701
  // Provenance-checked like the rest.
3525
3702
  if (psym !== undefined &&
3526
- ts.symbolName(psym) === "ErrnoException" &&
3703
+ psymName === "ErrnoException" &&
3527
3704
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3528
3705
  return { kind: "object", className: "%Error" };
3529
3706
  }
@@ -3534,7 +3711,7 @@ function mapTypeInner(type, ctx) {
3534
3711
  // of fencing at the declaration. Module-checked like the rest (https'
3535
3712
  // Agent extends http's; both live in their ambient modules).
3536
3713
  if (psym !== undefined &&
3537
- ts.symbolName(psym) === "Agent" &&
3714
+ psymName === "Agent" &&
3538
3715
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3539
3716
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3540
3717
  (isDeclaredInAmbientModule(d, "http") || isDeclaredInAmbientModule(d, "https")))) {
@@ -3543,12 +3720,12 @@ function mapTypeInner(type, ctx) {
3543
3720
  // http.IncomingMessage / http.ServerResponse — module-checked like
3544
3721
  // net.Server (the names repeat nowhere today, but provenance stays the
3545
3722
  // rule).
3546
- if (((psym !== undefined && ts.symbolName(psym) === "IncomingMessage") ||
3547
- (psym !== undefined && ts.symbolName(psym) === "ServerResponse")) &&
3723
+ if (((psym !== undefined && psymName === "IncomingMessage") ||
3724
+ (psym !== undefined && psymName === "ServerResponse")) &&
3548
3725
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3549
3726
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3550
3727
  isDeclaredInAmbientModule(d, "http"))) {
3551
- return ts.symbolName(psym) === "IncomingMessage" ? { kind: "httpReq" } : { kind: "httpRes" };
3728
+ return psymName === "IncomingMessage" ? { kind: "httpReq" } : { kind: "httpRes" };
3552
3729
  }
3553
3730
  // http2's compatibility surface (the allowHTTP1 lowering): the secure
3554
3731
  // server IS a net server (listen/close/address/emit ride the same
@@ -3558,15 +3735,15 @@ function mapTypeInner(type, ctx) {
3558
3735
  // ServerResponse surface. h2-only members (stream, session) fence per
3559
3736
  // member at their use sites (lower-server.ts). Module-checked like the
3560
3737
  // rest.
3561
- if (((psym !== undefined && ts.symbolName(psym) === "Http2SecureServer") ||
3562
- (psym !== undefined && ts.symbolName(psym) === "Http2ServerRequest") ||
3563
- (psym !== undefined && ts.symbolName(psym) === "Http2ServerResponse")) &&
3738
+ if (((psym !== undefined && psymName === "Http2SecureServer") ||
3739
+ (psym !== undefined && psymName === "Http2ServerRequest") ||
3740
+ (psym !== undefined && psymName === "Http2ServerResponse")) &&
3564
3741
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3565
3742
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3566
3743
  isDeclaredInAmbientModule(d, "http2"))) {
3567
- return ts.symbolName(psym) === "Http2SecureServer"
3744
+ return psymName === "Http2SecureServer"
3568
3745
  ? { kind: "netServer" }
3569
- : ts.symbolName(psym) === "Http2ServerRequest"
3746
+ : psymName === "Http2ServerRequest"
3570
3747
  ? { kind: "httpReq" }
3571
3748
  : { kind: "httpRes" };
3572
3749
  }
@@ -3574,25 +3751,25 @@ function mapTypeInner(type, ctx) {
3574
3751
  // like the secure one; sessions and streams are first-class handle
3575
3752
  // kinds (client and server flavors share a kind — the runtime handle
3576
3753
  // carries the role). Module-checked like the rest.
3577
- if (((psym !== undefined && ts.symbolName(psym) === "Http2Server") ||
3578
- (psym !== undefined && ts.symbolName(psym) === "Http2Session") ||
3579
- (psym !== undefined && ts.symbolName(psym) === "ClientHttp2Session") ||
3580
- (psym !== undefined && ts.symbolName(psym) === "ServerHttp2Session") ||
3581
- (psym !== undefined && ts.symbolName(psym) === "ClientHttp2Stream") ||
3582
- (psym !== undefined && ts.symbolName(psym) === "ServerHttp2Stream")) &&
3754
+ if (((psym !== undefined && psymName === "Http2Server") ||
3755
+ (psym !== undefined && psymName === "Http2Session") ||
3756
+ (psym !== undefined && psymName === "ClientHttp2Session") ||
3757
+ (psym !== undefined && psymName === "ServerHttp2Session") ||
3758
+ (psym !== undefined && psymName === "ClientHttp2Stream") ||
3759
+ (psym !== undefined && psymName === "ServerHttp2Stream")) &&
3583
3760
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3584
3761
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3585
3762
  isDeclaredInAmbientModule(d, "http2"))) {
3586
- return ts.symbolName(psym) === "Http2Server"
3763
+ return psymName === "Http2Server"
3587
3764
  ? { kind: "netServer" }
3588
- : ts.symbolName(psym) === "ClientHttp2Stream" || ts.symbolName(psym) === "ServerHttp2Stream"
3765
+ : psymName === "ClientHttp2Stream" || psymName === "ServerHttp2Stream"
3589
3766
  ? { kind: "http2Stream" }
3590
3767
  : { kind: "http2Session" };
3591
3768
  }
3592
3769
  // http.ClientRequest (http.request/http.get results) — module-checked
3593
3770
  // like IncomingMessage.
3594
3771
  if (psym !== undefined &&
3595
- ts.symbolName(psym) === "ClientRequest" &&
3772
+ psymName === "ClientRequest" &&
3596
3773
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3597
3774
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3598
3775
  isDeclaredInAmbientModule(d, "http"))) {
@@ -3607,7 +3784,7 @@ function mapTypeInner(type, ctx) {
3607
3784
  // declarations' anonymous env type takes the pureIndexShape path below
3608
3785
  // and interns the SAME shape.
3609
3786
  if (psym !== undefined &&
3610
- ts.symbolName(psym) === "ProcessEnv" &&
3787
+ psymName === "ProcessEnv" &&
3611
3788
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3612
3789
  const value = withUndefinedArm(STRING, ctx.unions);
3613
3790
  if (!value)
@@ -3654,8 +3831,10 @@ function mapTypeInner(type, ctx) {
3654
3831
  return { kind: "generator", yieldT, retT: VOID, nextT: UNDEFINED_T };
3655
3832
  }
3656
3833
  // Generator<T, TReturn, TNext>, AsyncGenerator<T, TReturn, TNext> (and
3657
- // the lib's IterableIterator<T, ...>, the older sync annotation spelling):
3658
- // the generator kind. Channel normalization keeps the runtime honest:
3834
+ // the lib's IterableIterator<T, ...>, the older sync annotation spelling;
3835
+ // AsyncIterator<T>, AsyncIterableIterator<T> and AsyncIterable<T>, what
3836
+ // `for await` consumes): the generator kind. Channel normalization keeps
3837
+ // the runtime honest:
3659
3838
  // yield channel — T must be a real value type (a generator that could
3660
3839
  // only yield undefined has no C value form); `never`
3661
3840
  // (a generator that never yields) rides the VOID
@@ -3684,19 +3863,32 @@ function mapTypeInner(type, ctx) {
3684
3863
  isStdlibInterface("Iterator") ||
3685
3864
  // IteratorObject<T> is what the iterator helpers return: a helper
3686
3865
  // generator over its source (containers/iterator-helpers.ts).
3687
- isStdlibInterface("IteratorObject")) {
3866
+ isStdlibInterface("IteratorObject") ||
3867
+ isAsyncIterationProtocol()) {
3688
3868
  const args = checker.getTypeArguments(widened);
3689
3869
  const channels = genChannels(args[0], args[1], args[2], ctx);
3690
3870
  if (!channels)
3691
3871
  return null;
3872
+ // The async iteration protocols are what `for await` CONSUMES: the
3873
+ // yield channel is the only promise they make. A for-await consumer
3874
+ // sends nothing back, and a producer's own return and resume
3875
+ // channels are its business, so the protocol spelling takes the
3876
+ // return channel as valueless and the resume channel as the
3877
+ // checked-dynamic one — the channels of the common
3878
+ // `AsyncGenerator<T, void, unknown>` producer annotation.
3879
+ const consumer = isAsyncIterationProtocol()
3880
+ ? { ...channels, retT: VOID, nextT: DYN }
3881
+ : channels;
3692
3882
  // The result record must exist too (its union must be legal), or
3693
3883
  // `.next()` could never answer — mapped generators always resume.
3694
- if (!genResultRecord(channels.yieldT, channels.retT, ctx.shapes, unions))
3884
+ if (!genResultRecord(consumer.yieldT, consumer.retT, ctx.shapes, unions))
3695
3885
  return null;
3696
3886
  return {
3697
3887
  kind: "generator",
3698
- ...(isStdlibInterface("AsyncGenerator") ? { async: true } : {}),
3699
- ...channels,
3888
+ ...(isStdlibInterface("AsyncGenerator") || isAsyncIterationProtocol()
3889
+ ? { async: true }
3890
+ : {}),
3891
+ ...consumer,
3700
3892
  };
3701
3893
  }
3702
3894
  // Iterable<T>: the iterable union (iterableUnionType) — the source value
@@ -3790,6 +3982,37 @@ function mapTypeInner(type, ctx) {
3790
3982
  ], false, undefined, ["encoding", "cwd", "input", "timeout", "stdio", "maxBuffer", "windowsHide"]),
3791
3983
  };
3792
3984
  }
3985
+ // child_process.SpawnSyncOptionsWithStringEncoding: the spawnSync twin of
3986
+ // the exec-options record above, interned explicitly for the same
3987
+ // reason — a typed const or a runner function's options parameter is a
3988
+ // runtime record the spawnSync lowering reads member by member. The
3989
+ // members are the ones it honestly implements: encoding (required — the
3990
+ // "WithStringEncoding" refinement), cwd/input/timeout/shell/stdio (a
3991
+ // runtime array is string[]; unsupported runtime modes throw at the
3992
+ // call), and the accepted-but-inert windowsHide. env and killSignal
3993
+ // stay literal-only, so their presence keeps the shape unmatched and
3994
+ // their literals fence at the shape check instead of being dropped.
3995
+ if (isStdlibInterface("SpawnSyncOptionsWithStringEncoding")) {
3996
+ const optStr = withUndefinedArm(STRING, ctx.unions);
3997
+ const optNum = withUndefinedArm(F64, ctx.unions);
3998
+ const optBool = withUndefinedArm(BOOL, ctx.unions);
3999
+ const stdioArms = [arrayOf(STRING), STRING, UNDEFINED_T].sort((a, b) => typeKey(a) < typeKey(b) ? -1 : 1);
4000
+ const stdio = { kind: "union", unionId: ctx.unions.intern(stdioArms) };
4001
+ if (!optStr || !optNum || !optBool)
4002
+ return null;
4003
+ return {
4004
+ kind: "record",
4005
+ shapeId: ctx.shapes.intern([
4006
+ { name: "cwd", type: optStr },
4007
+ { name: "encoding", type: STRING },
4008
+ { name: "input", type: optStr },
4009
+ { name: "shell", type: optBool },
4010
+ { name: "stdio", type: stdio },
4011
+ { name: "timeout", type: optNum },
4012
+ { name: "windowsHide", type: optBool },
4013
+ ], false, undefined, ["encoding", "cwd", "input", "timeout", "shell", "stdio", "windowsHide"]),
4014
+ };
4015
+ }
3793
4016
  if (isStdlibInterface("AddressInfo")) {
3794
4017
  return {
3795
4018
  kind: "record",
@@ -3833,10 +4056,10 @@ function mapTypeInner(type, ctx) {
3833
4056
  return DYN;
3834
4057
  // Filesystem options are data records. Keep their declared optional fields
3835
4058
  // instead of allowing arbitrary standard-library interfaces into records.
3836
- if (((psym !== undefined && ts.symbolName(psym) === "FileReadOptions") ||
3837
- (psym !== undefined && ts.symbolName(psym) === "ReadOptions") ||
3838
- (psym !== undefined && ts.symbolName(psym) === "ReadOptionsWithBuffer") ||
3839
- (psym !== undefined && ts.symbolName(psym) === "WriteOptions")) &&
4059
+ if (((psym !== undefined && psymName === "FileReadOptions") ||
4060
+ (psym !== undefined && psymName === "ReadOptions") ||
4061
+ (psym !== undefined && psymName === "ReadOptionsWithBuffer") ||
4062
+ (psym !== undefined && psymName === "WriteOptions")) &&
3840
4063
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3841
4064
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3842
4065
  (isDeclaredInAmbientModule(d, "fs/promises") || isDeclaredInAmbientModule(d, "fs")))) {
@@ -3857,24 +4080,24 @@ function mapTypeInner(type, ctx) {
3857
4080
  // null-prototype objects returned by FileHandle.read/write. The native
3858
4081
  // record does not model the prototype (unobservable through the lowered
3859
4082
  // surface); it preserves the caller buffer/string by reference.
3860
- if (((psym !== undefined && ts.symbolName(psym) === "FileReadResult") ||
3861
- (psym !== undefined && ts.symbolName(psym) === "FileWriteResult") ||
3862
- (psym !== undefined && ts.symbolName(psym) === "FileReadvResult") ||
3863
- (psym !== undefined && ts.symbolName(psym) === "FileWritevResult") ||
3864
- (psym !== undefined && ts.symbolName(psym) === "ReadVResult") ||
3865
- (psym !== undefined && ts.symbolName(psym) === "WriteVResult")) &&
4083
+ if (((psym !== undefined && psymName === "FileReadResult") ||
4084
+ (psym !== undefined && psymName === "FileWriteResult") ||
4085
+ (psym !== undefined && psymName === "FileReadvResult") ||
4086
+ (psym !== undefined && psymName === "FileWritevResult") ||
4087
+ (psym !== undefined && psymName === "ReadVResult") ||
4088
+ (psym !== undefined && psymName === "WriteVResult")) &&
3866
4089
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
3867
4090
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
3868
4091
  (isDeclaredInAmbientModule(d, "fs/promises") ||
3869
- ((ts.symbolName(psym) === "ReadVResult" || ts.symbolName(psym) === "WriteVResult") &&
4092
+ ((psymName === "ReadVResult" || psymName === "WriteVResult") &&
3870
4093
  isDeclaredInAmbientModule(d, "fs"))))) {
3871
4094
  const args = checker.getTypeArguments(widened);
3872
4095
  if (args.length !== 1)
3873
4096
  return null;
3874
- const vector = ts.symbolName(psym) === "FileReadvResult" ||
3875
- ts.symbolName(psym) === "FileWritevResult" ||
3876
- ts.symbolName(psym) === "ReadVResult" ||
3877
- ts.symbolName(psym) === "WriteVResult";
4097
+ const vector = psymName === "FileReadvResult" ||
4098
+ psymName === "FileWritevResult" ||
4099
+ psymName === "ReadVResult" ||
4100
+ psymName === "WriteVResult";
3878
4101
  const emptyVector = vector &&
3879
4102
  checker.isArrayType(args[0]) &&
3880
4103
  (checker.getTypeArguments(args[0])[0].flags & ts.TypeFlags.Never) !== 0;
@@ -3885,9 +4108,7 @@ function mapTypeInner(type, ctx) {
3885
4108
  : !(payload.kind === "string" || (payload.kind === "bytes" && payload.elem === "u8")))) {
3886
4109
  return null;
3887
4110
  }
3888
- const count = ts.symbolName(psym) === "FileReadResult" ||
3889
- ts.symbolName(psym) === "FileReadvResult" ||
3890
- ts.symbolName(psym) === "ReadVResult"
4111
+ const count = psymName === "FileReadResult" || psymName === "FileReadvResult" || psymName === "ReadVResult"
3891
4112
  ? "bytesRead"
3892
4113
  : "bytesWritten";
3893
4114
  const payloadName = vector ? "buffers" : "buffer";
@@ -3914,7 +4135,7 @@ function mapTypeInner(type, ctx) {
3914
4135
  // declares it concrete (an interface; @types/node uses a class — both
3915
4136
  // provenance-checked, the Buffer/URL pattern).
3916
4137
  if (psym !== undefined &&
3917
- ts.symbolName(psym) === "Dirent" &&
4138
+ psymName === "Dirent" &&
3918
4139
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
3919
4140
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
3920
4141
  const args = checker.getTypeArguments(widened);
@@ -4004,6 +4225,20 @@ function mapTypeInner(type, ctx) {
4004
4225
  ], false, undefined, ["uid", "gid", "username", "homedir", "shell"]),
4005
4226
  };
4006
4227
  }
4228
+ // os.BufferUserInfo: os.userInfo({ encoding: 'buffer' }) — the same
4229
+ // record with the three passwd strings as Buffers (the u8 bytes kind).
4230
+ if (isStdlibInterface("BufferUserInfo")) {
4231
+ return {
4232
+ kind: "record",
4233
+ shapeId: ctx.shapes.intern([
4234
+ { name: "gid", type: F64 },
4235
+ { name: "homedir", type: bytesOf("u8") },
4236
+ { name: "shell", type: bytesOf("u8") },
4237
+ { name: "uid", type: F64 },
4238
+ { name: "username", type: bytesOf("u8") },
4239
+ ], false, undefined, ["uid", "gid", "username", "homedir", "shell"]),
4240
+ };
4241
+ }
4007
4242
  // The promisified exec/execFile result `{ stdout: string; stderr: string }`
4008
4243
  // and the promisified dns.lookupService result `{ hostname: string;
4009
4244
  // service: string }`: anonymous type literals (@types/node's
@@ -4045,8 +4280,7 @@ function mapTypeInner(type, ctx) {
4045
4280
  // mapped property types (KeyObjects, PEM strings or DER Buffers), in
4046
4281
  // Node's key order.
4047
4282
  if (psym !== undefined &&
4048
- (ts.symbolName(psym) === "KeyPairKeyObjectResult" ||
4049
- ts.symbolName(psym) === "KeyPairSyncResult") &&
4283
+ (psymName === "KeyPairKeyObjectResult" || psymName === "KeyPairSyncResult") &&
4050
4284
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) &&
4051
4285
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
4052
4286
  isDeclaredInAmbientModule(d, "crypto"))) {
@@ -4069,8 +4303,7 @@ function mapTypeInner(type, ctx) {
4069
4303
  // X509Certificate.toLegacyObject()'s PeerCertificate (and tls's detailed
4070
4304
  // form) is a plain checked-dynamic object.
4071
4305
  if (psym !== undefined &&
4072
- (ts.symbolName(psym) === "PeerCertificate" ||
4073
- ts.symbolName(psym) === "DetailedPeerCertificate") &&
4306
+ (psymName === "PeerCertificate" || psymName === "DetailedPeerCertificate") &&
4074
4307
  psym.declarations.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
4075
4308
  return DYN;
4076
4309
  }
@@ -4082,7 +4315,7 @@ function mapTypeInner(type, ctx) {
4082
4315
  // it. JSON.stringify of one shows the fields where Node's internal-slot
4083
4316
  // object shows {} — the Dirent %dtype edge's cousin.
4084
4317
  if (psym !== undefined &&
4085
- ts.symbolName(psym) === "X509Certificate" &&
4318
+ psymName === "X509Certificate" &&
4086
4319
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
4087
4320
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)) &&
4088
4321
  isDeclaredInAmbientModule(d, "crypto"))) {
@@ -4106,9 +4339,9 @@ function mapTypeInner(type, ctx) {
4106
4339
  // record (util.inspect names the class from entryType, like Node).
4107
4340
  // @types/node declares the classes in perf_hooks and global interfaces
4108
4341
  // over them; the shipped fallback declares the classes.
4109
- if (((psym !== undefined && ts.symbolName(psym) === "PerformanceEntry") ||
4110
- (psym !== undefined && ts.symbolName(psym) === "PerformanceMark") ||
4111
- (psym !== undefined && ts.symbolName(psym) === "PerformanceMeasure")) &&
4342
+ if (((psym !== undefined && psymName === "PerformanceEntry") ||
4343
+ (psym !== undefined && psymName === "PerformanceMark") ||
4344
+ (psym !== undefined && psymName === "PerformanceMeasure")) &&
4112
4345
  psym.declarations.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
4113
4346
  ctx.isStdlibFile(ts.getSourceFileOfNode(d)))) {
4114
4347
  return { kind: "record", shapeId: perfEntryShape(ctx.shapes, ctx.unions) };
@@ -4340,6 +4573,33 @@ function mapTypeInner(type, ctx) {
4340
4573
  // the stream object hands out (scr_events.c ProcessStream).
4341
4574
  if (callSigs.length > 1 && isStdlibStreamWriteOverloads(callSigs, ctx))
4342
4575
  return DYN;
4576
+ // An overload set held as a VALUE (a callback parameter, an alias, a
4577
+ // variable, a member read): JavaScript stores ONE function, so the value
4578
+ // is that function's erased type, the same slot a record member of this
4579
+ // type stores (erasedOverloadMemberType). Calls through it convert the
4580
+ // result back to the resolved overload's type (lowerCallThroughValue).
4581
+ if (callSigs.length > 1 && isOverloadedCallableMemberType(widened, checker)) {
4582
+ const erased = erasedOverloadMemberType(widened, ctx);
4583
+ if (erased !== undefined)
4584
+ return erased;
4585
+ }
4586
+ // A generic signature as a VALUE (`const f: <T>(x: T) => T`, a generic
4587
+ // method's record slot, a union arm holding one): JavaScript erases type
4588
+ // parameters, so the value is the ONE function every instantiation calls,
4589
+ // and its type is that signature with each own type parameter bound to
4590
+ // `unknown` — the erased func type erasedGenericMemberType /
4591
+ // erasedOverloadMemberType already answer for generic-callable members.
4592
+ // The calls that instantiate it convert their arguments in and their
4593
+ // result out (lower-calls.ts, genericValueCall). A signature whose
4594
+ // erasure does not map (a rest parameter, an unmappable position) keeps
4595
+ // the fences below: undefined falls through to mapCallSignature's null.
4596
+ if (erasedGenericSignatureType(widened, callSigs, ctx)) {
4597
+ const erased = callSigs.length === 1
4598
+ ? erasedGenericMemberType(widened, ctx)
4599
+ : erasedOverloadMemberType(widened, ctx);
4600
+ if (erased !== undefined)
4601
+ return erased;
4602
+ }
4343
4603
  if (callSigs.length === 1)
4344
4604
  return mapCallSignature(callSigs[0], ctx);
4345
4605
  // Records: object types whose members are all data properties (shorthand
@@ -4460,6 +4720,43 @@ function mapTypeInner(type, ctx) {
4460
4720
  });
4461
4721
  if (childShaped && core >= 2)
4462
4722
  return CHILD_T;
4723
+ // A USER-declared writable-pipe interface — the writer half of the same
4724
+ // idiom (a hand-written `Pipe { write(chunk: string): boolean; end():
4725
+ // void }` naming child.stdin). Every member is named on the child
4726
+ // stdin surface, `write` takes a chunk the writer takes (a string, or
4727
+ // bytes such as a Uint8Array/Buffer) and answers the backpressure
4728
+ // boolean, and at least one other member says writer (a lone `write`
4729
+ // member is an ordinary record holding a function). The type maps to
4730
+ // the child writer handle: in a compiled program the only VALUE
4731
+ // producer is spawn's child.stdin, and the members lower against it.
4732
+ const chunkIsWritten = (chunk) => {
4733
+ const arms = chunk.kind === "union" ? (ctx.unions.get(chunk.unionId)?.arms ?? []) : [chunk];
4734
+ return (arms.length > 0 &&
4735
+ arms.every((arm) => arm.kind === "string" || (arm.kind === "bytes" && arm.elem === "u8")));
4736
+ };
4737
+ const writeMember = (p) => {
4738
+ const sigs = checker.getCallSignatures(checker.getTypeOfSymbol(p));
4739
+ if (sigs.length !== 1)
4740
+ return false;
4741
+ const sig = sigs[0];
4742
+ const params = sig.getParameters();
4743
+ if (params.length < 1 || params.length > 2)
4744
+ return false;
4745
+ if ((checker.getReturnTypeOfSignature(sig).flags & ts.TypeFlags.Boolean) === 0)
4746
+ return false;
4747
+ const chunk = mapType(checker.getTypeOfSymbol(params[0]), ctx);
4748
+ return chunk !== null && chunkIsWritten(chunk);
4749
+ };
4750
+ const writerProps = checker.getPropertiesOfType(widened);
4751
+ const writerShaped = writerProps.length >= 2 &&
4752
+ writerProps.some((p) => ts.symbolName(p) === "write" && writeMember(p)) &&
4753
+ writerProps.every((p) => CHILD_WRITER_MEMBERS.has(ts.symbolName(p)) &&
4754
+ (ts.symbolName(p) !== "write" || writeMember(p)));
4755
+ if (writerShaped) {
4756
+ return ctx.generalNodeStreams === true
4757
+ ? { kind: "object", className: "%Writable" }
4758
+ : { kind: "childWriter" };
4759
+ }
4463
4760
  }
4464
4761
  if (flags & (ts.TypeFlags.Object | ts.TypeFlags.Intersection) && callSigs.length === 0) {
4465
4762
  const viaMapped = mapBoundMappedType(widened, ctx);
@@ -4518,6 +4815,7 @@ function mapTypeInner(type, ctx) {
4518
4815
  try {
4519
4816
  const byKey = new Map();
4520
4817
  const recordParts = [];
4818
+ const classParts = [];
4521
4819
  const substitutedUnions = [];
4522
4820
  // The lib's `T extends readonly unknown[] | []` idiom (Promise.all,
4523
4821
  // allSettled) maps an array input to `X[] | []`: the empty tuple is
@@ -4608,6 +4906,19 @@ function mapTypeInner(type, ctx) {
4608
4906
  byKey.set(typeKey(mapped), mapped);
4609
4907
  if (mapped.kind === "record")
4610
4908
  recordParts.push({ source: part, mapped });
4909
+ if (mapped.kind === "object")
4910
+ classParts.push({ source: part, mapped });
4911
+ }
4912
+ // A subclass arm beside one of its ancestor classes (`Shape | Circle`
4913
+ // with `class Circle extends Shape`) is that ancestor: every instance
4914
+ // of the subclass is an instance of the ancestor, the ancestor's slot
4915
+ // holds it as the same pointer, and `instanceof` and member dispatch
4916
+ // read the instance's own class. A union would box each value.
4917
+ if (classParts.length > 1) {
4918
+ for (const { source, mapped } of classParts) {
4919
+ if (programClassBases(source, ctx).some((base) => byKey.has(typeKey(base))))
4920
+ byKey.delete(typeKey(mapped));
4921
+ }
4611
4922
  }
4612
4923
  const arms = [...byKey.values()];
4613
4924
  if (arms.length === 0)
@@ -4723,6 +5034,37 @@ function mapTypeInner(type, ctx) {
4723
5034
  }
4724
5035
  return null;
4725
5036
  }
5037
+ /** The classes a non-generic program class extends, nearest first, as
5038
+ * long as each is a non-generic class the program declares. Empty for
5039
+ * other types. */
5040
+ function programClassBases(instance, ctx) {
5041
+ const bases = [];
5042
+ let current = instance;
5043
+ while (bases.length < MAP_TYPE_MAX_DEPTH) {
5044
+ if (!programClassDeclaration(current, ctx))
5045
+ break;
5046
+ const base = ctx.checker.getBaseTypes(current)[0];
5047
+ if (base === undefined || !programClassDeclaration(base, ctx))
5048
+ break;
5049
+ const mapped = mapType(base, ctx);
5050
+ if (mapped?.kind !== "object")
5051
+ break;
5052
+ bases.push(mapped);
5053
+ current = base;
5054
+ }
5055
+ return bases;
5056
+ }
5057
+ /** Whether `type` is the instance type of a non-generic class declared in
5058
+ * the program's source. */
5059
+ function programClassDeclaration(type, ctx) {
5060
+ if ((type.flags & ts.TypeFlags.Object) === 0 || !type.isClassOrInterface())
5061
+ return false;
5062
+ const decl = type.getSymbol()?.valueDeclaration;
5063
+ if (decl === undefined || !ts.isClassDeclaration(decl) || decl.typeParameters?.nodes.length)
5064
+ return false;
5065
+ const file = ts.getSourceFileOfNode(decl);
5066
+ return !file.isDeclarationFile && ctx.isProgramFile(file);
5067
+ }
4726
5068
  /** One non-overloaded call signature's func type (mapTypeInner's
4727
5069
  * single-signature rule; erasedOverloadMemberType maps each overload of a
4728
5070
  * member through it). */
@@ -6897,6 +7239,70 @@ function packageTypeFile(sf, ctx) {
6897
7239
  (/[\\/]node_modules[\\/]/.test(sf.fileName) || ctx.isExperimentalFile?.(sf) === true) &&
6898
7240
  !ctx.isStdlibFile(sf));
6899
7241
  }
7242
+ /** `type`'s declarations — through its alias, or its own symbol when the
7243
+ * checker gives it no alias — when EVERY one is a declaration-file
7244
+ * declaration outside the standard library and the external type
7245
+ * surfaces; null otherwise. */
7246
+ function packageDeclarations(sym, ctx) {
7247
+ const decls = sym ? sym.declarations : undefined;
7248
+ return decls &&
7249
+ decls.length > 0 &&
7250
+ decls.every((d) => {
7251
+ const sf = ts.getSourceFileOfNode(d);
7252
+ return sf.isDeclarationFile && !ctx.isStdlibFile(sf) && !ctx.isExternalTypeFile(sf);
7253
+ })
7254
+ ? decls
7255
+ : null;
7256
+ }
7257
+ /** One non-union part's package provenance: true when the part is
7258
+ * package-declared as data, false when it is package-declared with a value
7259
+ * or implementation shape, null when no package declares it. */
7260
+ function packageDataPart(type, ctx) {
7261
+ const aliasDecls = packageDeclarations(type.getAliasSymbol(), ctx);
7262
+ const ownDecls = packageDeclarations(type.getSymbol(), ctx);
7263
+ if (aliasDecls === null && (type.getAliasSymbol() !== undefined || ownDecls === null))
7264
+ return null;
7265
+ return purePackageDeclarations(aliasDecls, ctx) && purePackageDeclarations(ownDecls, ctx);
7266
+ }
7267
+ /** True when EVERY declaration `type` is spelled by is a pure data
7268
+ * declaration (interface, type alias, object or mapped type literal,
7269
+ * declared data class, type-only namespace) in a package declaration file —
7270
+ * no value declaration merged in, no class implementation. */
7271
+ function purePackageDeclarations(decls, ctx) {
7272
+ return (decls === null ||
7273
+ decls.every((d) => packageTypeFile(ts.getSourceFileOfNode(d), ctx) &&
7274
+ (ts.isInterfaceDeclaration(d) ||
7275
+ ts.isTypeAliasDeclaration(d) ||
7276
+ ts.isTypeLiteralNode(d) ||
7277
+ ts.isMappedTypeNode(d) ||
7278
+ isDeclaredDataClass(d) ||
7279
+ (decls.some(isDeclaredDataClass) && isTypeOnlyNamespace(d)))));
7280
+ }
7281
+ /** True when `type` is PACKAGE-DECLARED as data: some part of its
7282
+ * provenance is a package declaration, and no declaration it reaches is a
7283
+ * value or implementation shape. Such a type describes data the PROGRAM
7284
+ * built — `import type` from a package whose implementation is not part of
7285
+ * the compiled module graph — so the structural rules map it like a local
7286
+ * declaration, and a shape they cannot map is still that data, held as the
7287
+ * checked-dynamic value (`mapTypeEntry`'s fallback). A member the package
7288
+ * does not declare (a scalar beside a recursive knot) carries no provenance
7289
+ * of its own. */
7290
+ export function packageTypeIsData(type, ctx) {
7291
+ // `npmPackageOf` reaches the declaring package through the union's
7292
+ // members; the value-shape test is per member and never recurses (a
7293
+ // recursive alias reaches itself here).
7294
+ const parts = type.isUnionType() ? ts.constituentTypes(type) : [type];
7295
+ let declared = false;
7296
+ for (const part of parts) {
7297
+ const data = packageDataPart(part, ctx);
7298
+ if (data === null)
7299
+ continue;
7300
+ declared = true;
7301
+ if (!data)
7302
+ return false;
7303
+ }
7304
+ return declared;
7305
+ }
6900
7306
  /** The record path's provenance fence. Declared shapes (object literals,
6901
7307
  * interfaces, type literals) must come from user code or an explicitly
6902
7308
  * mapped external type surface, never an arbitrary .d.ts — the empty
@@ -6996,6 +7402,26 @@ function mentionsErasedTypeParam(type, ctx, depth) {
6996
7402
  return true;
6997
7403
  return false;
6998
7404
  }
7405
+ /** A type whose call signatures keep their own type parameters and that is
7406
+ * pure function-shaped — call signatures only, no data properties, no
7407
+ * construct or index signatures: the type of a generic function held as a
7408
+ * value (`const f: <T>(x: T) => T`, an interface's generic method, a union
7409
+ * arm naming one). mapType answers its erased func type
7410
+ * (erasedGenericMemberType / erasedOverloadMemberType). False while the
7411
+ * active erasure already IS one of these signatures: that mapping is
7412
+ * mapCallSignature's own, and re-entering the erasure would recurse. */
7413
+ function erasedGenericSignatureType(t, sigs, ctx) {
7414
+ if (sigs.length === 0)
7415
+ return false;
7416
+ if (!sigs.some((sig) => sig.getTypeParameters().length > 0))
7417
+ return false;
7418
+ if (ctx.erasingSignature !== undefined && sigs.includes(ctx.erasingSignature))
7419
+ return false;
7420
+ const { checker } = ctx;
7421
+ return (checker.getConstructSignatures(t).length === 0 &&
7422
+ checker.getPropertiesOfType(t).length === 0 &&
7423
+ checker.getIndexInfosOfType(t).length === 0);
7424
+ }
6999
7425
  /** A generic callable member's runtime type: its one call signature with
7000
7426
  * every own type parameter bound to `unknown`, the erased instance a stored
7001
7427
  * or escaping definition carries (JavaScript erases type parameters the
@@ -7031,12 +7457,14 @@ export function erasedGenericMemberType(t, ctx) {
7031
7457
  }
7032
7458
  /** An OVERLOADED callable member type (`on(event: "a", h: (x: number) =>
7033
7459
  * void): () => void; on(event: "b", h: (x: string) => void): () => void`
7034
- * in a program interface or type literal): two or more call signatures and
7460
+ * in a program interface or type literal, or a class's body-less overload
7461
+ * declarations above its implementation): two or more call signatures and
7035
7462
  * nothing else (no data properties, construct signatures, or index
7036
7463
  * signatures), every one declared in TypeScript program source. Such a
7037
7464
  * member keeps a record slot holding its erased runtime function
7038
7465
  * (erasedOverloadMemberType); calls convert per their resolved overload
7039
- * (lowerRecordFieldCall). */
7466
+ * (lowerRecordFieldCall). An overload set held as a value maps to the same
7467
+ * erased function (mapTypeInner). */
7040
7468
  export function isOverloadedCallableMemberType(t, checker) {
7041
7469
  const sigs = checker.getCallSignatures(t);
7042
7470
  if (sigs.length < 2)
@@ -7049,7 +7477,12 @@ export function isOverloadedCallableMemberType(t, checker) {
7049
7477
  const decl = sig.declaration;
7050
7478
  if (decl === undefined)
7051
7479
  return false;
7052
- if (!ts.isMethodSignatureDeclaration(decl) && !ts.isCallSignatureDeclaration(decl))
7480
+ // Interface and type-literal members, call signatures, and a class's
7481
+ // body-less overload declarations (`getAuth(id: string): R;` above its
7482
+ // implementation): each names one overload of ONE stored function.
7483
+ if (!ts.isMethodSignatureDeclaration(decl) &&
7484
+ !ts.isCallSignatureDeclaration(decl) &&
7485
+ !(ts.isMethodDeclaration(decl) && decl.body === undefined))
7053
7486
  return false;
7054
7487
  const file = ts.getSourceFileOfNode(decl);
7055
7488
  return !file.isDeclarationFile && !isJsSourceFile(file);
@@ -8131,6 +8564,14 @@ function mergePromiseArms(arms, ctx) {
8131
8564
  // exactly `Promise<void>`.
8132
8565
  if (payload.every((arm) => arm.kind === "undefinedT"))
8133
8566
  payload.length = 0;
8567
+ // SEVERAL MODULE NAMESPACES are ONE checked-dynamic payload: a namespace
8568
+ // has no union tag (its value is the module's namespace object, built by
8569
+ // the same dynamic box a bare namespace value crosses as), so JavaScript
8570
+ // cannot tell the merged arms apart — `then((m) => …)` reads a namespace
8571
+ // object either way. The joint payload is that object, exactly what
8572
+ // `Promise<unknown>` settles here (moduleNamespacePromiseDynValue).
8573
+ else if (payload.length > 1 && payload.every((arm) => arm.kind === "moduleNs"))
8574
+ payload.splice(0, payload.length, DYN);
8134
8575
  // One payload arm is that arm itself (a regex or a promise payload has a
8135
8576
  // promise slot but no union arm); a JOINT payload is a union, so its arms
8136
8577
  // need union homes.