@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
@@ -57,7 +57,7 @@ import { cjsLexedExportsOfFile, cjsVisibleNames } from "./cjs-syntax.js";
57
57
  import { ambientDtsPath, fallbackDtsPath, fallbackModulesNamedIn, isFallbackDtsPath, isNodeTypesPath, overridesDtsPath, tsgoPath, } from "./dts-paths.js";
58
58
  import { builtinDefaultImportModule, canonicalBuiltinModule, npmBuiltinAliasOf, SUPPORTED_NODE_MODULES, unsupportedModuleFeatureOf, TEMPORAL_GLOBAL, } from "./builtin-modules.js";
59
59
  import { clearWorkspacePackages, isRelativeSpecifier, isWorkspacePackageName, npmPackageNameOf, packageNameOfSpecifier, registerWorkspacePackage, workspacePackageOfPath, } from "./workspace-registry.js";
60
- import { ADOPTED_OPTIONS, isJsSourceFileName, JS_ANY_OPERATOR_CODES, JS_RELAXED_TSC_CODES, } from "./tsc-codes.js";
60
+ import { ADOPTED_OPTIONS, isJsSourceFileName, jsOpinion, jsTscCodeTriage, } from "./tsc-codes.js";
61
61
  import { trackedFileExists, trackedReadFile, trackedRealpath } from "./input-tracker.js";
62
62
  import { earlyErrorDiagnostics7 } from "./early-errors.js";
63
63
  import { forkTargetPaths } from "./fork-target.js";
@@ -1173,71 +1173,103 @@ function declBoundaryDroppedDiag(file) {
1173
1173
  * preflight diagnostics. Preserve the caller's complete load shape when
1174
1174
  * mutating it, including its owned services and disposal callback. */
1175
1175
  export function checkPreflight(load) {
1176
- const { diags, moduleOrder, startupCrash, inlineRequireCycleCalls, moduleEdges, dynamicImportRejections, } = preflight7(load);
1176
+ const { diags, moduleOrder, startupCrash, inlineRequireCycleCalls, moduleEdges, dynamicImportRejections, admittedOpinions, } = preflight7(load);
1177
1177
  load.moduleOrder = moduleOrder;
1178
1178
  load.startupCrash = startupCrash;
1179
1179
  load.inlineRequireCycleCalls = inlineRequireCycleCalls;
1180
1180
  load.moduleEdges = moduleEdges;
1181
1181
  load.dynamicImportRejections = dynamicImportRejections;
1182
+ load.admittedOpinions = admittedOpinions;
1183
+ // Measurement aid: prints every opinion site this preflight admitted, so a
1184
+ // corpus run can show which rows carry evidence (SCRIPTC_DEBUG_ADMITTED=1).
1185
+ // Silent by default; no lowering reads the set.
1186
+ if (process.env["SCRIPTC_DEBUG_ADMITTED"] === "1")
1187
+ for (const site of admittedOpinions)
1188
+ process.stderr.write(`scriptc admitted TS${site.code} ${site.view} ${site.file}:${site.pos}-${site.end}\n`);
1182
1189
  return diags;
1183
1190
  }
1184
- /* Finding 5: tsgo's strict CommonJS modeling fires checker codes on JS
1185
- * shapes 5.9.3 accepted, and the real hazards those shapes carry are fenced
1186
- * by scriptc's OWN analysis, never by these codes — so for JS FILES ONLY
1187
- * they join the relaxation (TS sources keep the full gate; the order-parity
1188
- * harness holds both lanes to identical verdicts, so a case where 5.9.3
1189
- * itself raises one of these on a JS file would fail there, not slip by):
1190
- * - TS2309 ("export assignment with other exported elements") on the
1191
- * table-then-member pattern — cjsExportDiscardReason names every export
1192
- * Node actually discards.
1193
- * - TS2323 ("cannot redeclare exported variable") on symbol-keyed expando
1194
- * assignments in CJS classes (`this[kSym] = v` under `module.exports =
1195
- * Class`) — 5.9.3 synthesized expando symbols, tsgo trips its
1196
- * redeclaration check instead (the corpus's countdown fixture). */
1197
- // Ordinary JavaScript functions are constructable even when the checker
1198
- // retains only their call signature after a factory return. Heritage
1199
- // lowering separately verifies the actual constructor implementation.
1200
- const TS7_JS_RELAXED_EXTRA = new Set([2309, 2323, 2507]);
1201
- /** Relaxed JavaScript codes that checked JavaScript files keep: values of
1202
- * another type in a typed slot (2322 and its elaborations 2740/2741/2559,
1203
- * 2345, 2769), call arity (2554-2556) and incompatible subclass members
1204
- * (2415). */
1205
- const CHECKED_JS_ENFORCED_CODES = new Set([
1206
- 2322, 2345, 2415, 2554, 2555, 2556, 2559, 2740, 2741, 2769,
1207
- ]);
1208
- function suppressedJsStrictness7(d) {
1209
- const file = d.fileName;
1210
- if (!file || !isJsSourceFileName(file))
1211
- return false;
1212
- if (JS_RELAXED_TSC_CODES.has(d.code) || TS7_JS_RELAXED_EXTRA.has(d.code))
1213
- return true;
1214
- // The 8xxx range is TypeScript's JSDoc-specific diagnostic family
1215
- // (malformed tags, signature/tag mismatches): comment semantics with no
1216
- // runtime meaning in a JS file.
1217
- if (d.code >= 8000 && d.code <= 8999)
1218
- return true;
1219
- if (JS_ANY_OPERATOR_CODES.has(d.code)) {
1220
- const text = ts.flattenDiagnosticMessageText(d, "\n");
1221
- // A primitive wrapper operand (`new Number(1) * 2`): the operator
1222
- // converts it with ToPrimitive, as for any object.
1223
- return text.includes("'any'") || /'(Number|String|Boolean)'/.test(text);
1224
- }
1225
- // An index write on a String wrapper (`new String("ab")[5] = "q"`): Node
1226
- // adds the property past the end and ignores writes to the read-only
1227
- // index properties (sloppy) or throws (strict), as the object does.
1228
- if (d.code === 2542 && ts.flattenDiagnosticMessageText(d, "\n").includes("type 'String'"))
1229
- return true;
1230
- // The deprecated Buffer(...) call without `new`, which Node's Buffer
1231
- // function accepts (containers/bytes.ts lowers it), and fs.ReadStream(...)
1232
- // and fs.WriteStream(...), which construct their stream
1233
- // (builtins/fs-streams.ts).
1234
- if (d.code === 2348) {
1235
- const text = ts.flattenDiagnosticMessageText(d, "\n");
1236
- return (text.includes("'BufferConstructor'") ||
1237
- text.includes("'typeof ReadStream'") ||
1238
- text.includes("'typeof WriteStream'"));
1191
+ /** The module evaluation order and the graph facts derived with it, without
1192
+ * the diagnostics. `--npm-static`'s library fixpoint reloads the program
1193
+ * once per package it discovers and reads the order alone (to find the next
1194
+ * package); only the last program's diagnostics are ever reported, and its
1195
+ * checkPreflight completes this walk instead of repeating it. */
1196
+ export function checkModuleOrder(load) {
1197
+ registerWorkspaceEdges(load);
1198
+ fillPreflightFields(load, preflightStructure(load));
1199
+ }
1200
+ function fillPreflightFields(load, structure) {
1201
+ load.moduleOrder = structure.order;
1202
+ load.inlineRequireCycleCalls = structure.inlineRequireCycleCalls;
1203
+ load.moduleEdges = structure.moduleEdges;
1204
+ load.dynamicImportRejections = structure.dynamicImportRejections;
1205
+ }
1206
+ /** The innermost node whose token span contains [pos, end): the node an
1207
+ * opinion row's site guard inspects, and the one `island` rows ask about
1208
+ * (a diagnostic carries no node). */
1209
+ function diagnosticNode7(sf, pos, end) {
1210
+ let node = sf;
1211
+ // The lowering's nesting fence is 200 levels; a recovered AST is never
1212
+ // deeper than that on the path to one diagnostic.
1213
+ for (let depth = 0; depth < 200; depth++) {
1214
+ let next;
1215
+ ts.forEachChild(node, (child) => {
1216
+ if (ts.tokenStartOfNode(child) <= pos && end <= child.end) {
1217
+ next = child;
1218
+ return true;
1219
+ }
1220
+ return undefined;
1221
+ });
1222
+ if (next === undefined)
1223
+ break;
1224
+ node = next;
1239
1225
  }
1240
- return false;
1226
+ return node;
1227
+ }
1228
+ /** The JS_OPINIONS admission for one checker diagnostic (tsc-codes.ts), or
1229
+ * null when the diagnostic stays. Five conditions, in order:
1230
+ *
1231
+ * 1. the file is a JavaScript source (never .ts/.mts/.cts/.tsx/.d.ts);
1232
+ * 2. a row admits the code, and the file is unchecked JavaScript unless the
1233
+ * row is one a checked project has always seen (`checkedJs: "enforce"`);
1234
+ * 3. the diagnostic is a checker diagnostic, not a parser one (a syntactic
1235
+ * diagnostic leaves a recovered AST);
1236
+ * 4. the row's site guard accepts the diagnostic's node, if it has one;
1237
+ * 5. an `island` row does not apply in strict code (scriptc's own
1238
+ * isStrictCode, never tsc's module opinion).
1239
+ *
1240
+ * Admission says nothing about the LOWERING: the caller records the site
1241
+ * (AdmittedOpinion) so a view's lowering path can be gated on it. */
1242
+ function jsOpinionOf7(p, d, projectCheckJs, syntacticOf) {
1243
+ if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
1244
+ return null;
1245
+ const opinion = jsOpinion(d.code);
1246
+ if (opinion === null)
1247
+ return null;
1248
+ const sf = p.getSourceFile(d.fileName);
1249
+ if (sf !== undefined &&
1250
+ opinion.checkedJs === "enforce" &&
1251
+ isCheckedJsSourceFile(sf, projectCheckJs))
1252
+ return null;
1253
+ const pos = d.pos;
1254
+ const end = d.end;
1255
+ const spanless = pos === undefined || end === undefined;
1256
+ // A diagnostic with no span, or one that names a file the program does
1257
+ // not carry, cannot be placed in the AST. A row with no node guard needs
1258
+ // no node, so the admission applies exactly as it always has; the caller
1259
+ // records nothing (there is no site a view could be gated on).
1260
+ const nodeFree = opinion.site === undefined && opinion.view !== "island";
1261
+ if (spanless || sf === undefined)
1262
+ return nodeFree ? opinion : null;
1263
+ if (syntacticOf(sf).some((s) => s.code === d.code && s.pos === pos && s.end === end))
1264
+ return null;
1265
+ if (nodeFree)
1266
+ return opinion;
1267
+ const node = diagnosticNode7(sf, pos, end);
1268
+ if (opinion.site !== undefined && !opinion.site(node, d))
1269
+ return null;
1270
+ if (opinion.view === "island" && isStrictCode(node))
1271
+ return null;
1272
+ return opinion;
1241
1273
  }
1242
1274
  /** The specifier of a `require("...")` call: the callee is the bare
1243
1275
  * identifier `require` and the single argument a string literal. The one
@@ -2483,8 +2515,18 @@ function jsUndeclaredWriteDiags(program, files) {
2483
2515
  if (ts.isIdentifier(node) &&
2484
2516
  node.text !== "" &&
2485
2517
  isJsWriteTarget7(node) &&
2486
- undeclaredJsName7(checker, node))
2487
- diags.push(unsupportedDiag("SC1091", { file: sf.fileName, start: node.getStart(sf), end: node.end }, `writing the undeclared name '${node.text}' in a JavaScript source`));
2518
+ undeclaredJsName7(checker, node)) {
2519
+ const sloppyWrite = !isStrictCode(node);
2520
+ const diag = unsupportedDiag("SC1091", { file: sf.fileName, start: node.getStart(sf), end: node.end }, `writing the undeclared name '${node.text}' in a JavaScript source`);
2521
+ // A sloppy-mode write creates the global at run time, a sloppy-only
2522
+ // semantic the native tier does not implement: the reason lets an
2523
+ // automatic island policy put this module in a Node island instead
2524
+ // of refusing the build. A strict-mode write throws ReferenceError,
2525
+ // which is an ordinary lowering gap and stays a plain refusal.
2526
+ if (sloppyWrite)
2527
+ diag.reason = "implicit-global-write";
2528
+ diags.push(diag);
2529
+ }
2488
2530
  ts.forEachChild(node, (child) => {
2489
2531
  stack.push(child);
2490
2532
  return undefined;
@@ -2785,6 +2827,36 @@ function isCjsJsFile7(sf, program) {
2785
2827
  export function isCjsJsFile(sf, program) {
2786
2828
  return isCjsJsFile7(sf, program);
2787
2829
  }
2830
+ function hasUseStrictDirective(statements) {
2831
+ for (const statement of statements) {
2832
+ if (!ts.isExpressionStatement(statement) || !ts.isStringLiteral(statement.expression))
2833
+ return false;
2834
+ if (statement.expression.text === "use strict")
2835
+ return true;
2836
+ }
2837
+ return false;
2838
+ }
2839
+ /** Whether `node` runs in strict mode code: inside a class body, a function
2840
+ * with a "use strict" directive, a module, or a script that starts with
2841
+ * "use strict". CommonJS JavaScript is sloppy otherwise; the sloppy-only
2842
+ * semantics (implicit globals, `with`, direct eval, Annex B) need a Node
2843
+ * island. */
2844
+ export function isStrictCode(node) {
2845
+ for (let parent = node.parent; parent; parent = parent.parent) {
2846
+ if (ts.isClassDeclaration(parent) || ts.isClassExpression(parent))
2847
+ return true;
2848
+ if (ts.isFunctionLike(parent) &&
2849
+ parent.body &&
2850
+ ts.isBlock(parent.body) &&
2851
+ hasUseStrictDirective(parent.body.statements.nodes))
2852
+ return true;
2853
+ if (ts.isSourceFile(parent)) {
2854
+ return (hasUseStrictDirective(parent.statements.nodes) ||
2855
+ (!isCjsJsFile7(parent) && (isNodeEsmFile7(parent) || ts.isExternalModule(parent))));
2856
+ }
2857
+ }
2858
+ return false;
2859
+ }
2788
2860
  /** The self-import TDZ fences: for `import { x } from "<self>"` (default
2789
2861
  * and namespace forms included), any TOP-LEVEL reference lexically above
2790
2862
  * the aliased declaration observes Node's temporal dead zone — the direct
@@ -4892,13 +4964,18 @@ function typeOnlyNamespace7(decl) {
4892
4964
  * program, or null (unresolvable / outside the program). Exported (as
4893
4965
  * resolveImport) for the lowering: CommonJS require statements lower to
4894
4966
  * guarded %init calls of exactly the module preflight resolved here. */
4895
- function resolveImport7(program, from, specifier, resolutionKind = "import") {
4967
+ function resolveImport7(program, from, specifier, resolutionKind = "import",
4968
+ /** False for the graph passes that over-approximate edges (see
4969
+ * `resolveRuntimeEdge`): they resolve specifiers Node may never load, so
4970
+ * a miss there is no evidence about the package's entry and must not
4971
+ * classify it. The walks that model real loads pass the default. */
4972
+ reportMiss = true) {
4896
4973
  const resolved = resolveProjectModule(from.fileName, specifier);
4897
4974
  if (resolved !== null)
4898
4975
  return program.getSourceFile(resolved) ?? null;
4899
4976
  const npm = resolveNpmImport7(from.fileName, specifier, resolutionKind);
4900
4977
  return npm && isNpmStaticPackage(npm.packageName)
4901
- ? npmStaticProgramDep(program, npm.packageName, npm.typesFile)
4978
+ ? npmStaticProgramDep(program, npm.packageName, npm.typesFile, reportMiss)
4902
4979
  : null;
4903
4980
  }
4904
4981
  function resolveNpmImport7(fromFileName, specifier, resolutionKind = "import") {
@@ -4968,14 +5045,16 @@ function npmStaticProgramFile(program, resolvedFile) {
4968
5045
  * entry maps to, or null with the package marked an offender (resolution
4969
5046
  * still answering declarations, or the file missing from the type-checked
4970
5047
  * program — a path-identity mismatch between the two resolvers). */
4971
- function npmStaticProgramDep(program, packageName, resolvedFile) {
5048
+ function npmStaticProgramDep(program, packageName, resolvedFile, reportMiss = true) {
4972
5049
  if (!isJsSourceFileName(resolvedFile)) {
4973
- reportNpmStaticOffender(packageName, `its import resolves to '${resolvedFile}', not to runtime JavaScript`);
5050
+ if (reportMiss)
5051
+ reportNpmStaticOffender(packageName, `its import resolves to '${resolvedFile}', not to runtime JavaScript`);
4974
5052
  return null;
4975
5053
  }
4976
5054
  const dep = npmStaticProgramFile(program, resolvedFile);
4977
5055
  if (dep === null) {
4978
- reportNpmStaticOffender(packageName, `its entry '${resolvedFile}' did not join the type-checked program`);
5056
+ if (reportMiss)
5057
+ reportNpmStaticOffender(packageName, `its entry '${resolvedFile}' did not join the type-checked program`);
4979
5058
  return null;
4980
5059
  }
4981
5060
  return dep;
@@ -5030,27 +5109,42 @@ function declarationHasRuntimeFile(declaration) {
5030
5109
  return trackedFileExists(name.slice(0, -declared.length) + runtime);
5031
5110
  return false;
5032
5111
  }
5033
- function preflight7(load) {
5034
- const { program, entry } = load;
5035
- const diags = [...load.configDiags];
5036
- // An explicit entry can itself live in an installed package. Its own
5037
- // source files are program code, including relative barrels and sibling
5038
- // modules; their location must not erase the module graph.
5039
- // Match the full installed directory, not just the package name, and
5040
- // exclude nested installations so dependencies keep their npm policy.
5041
- const entryPackageFile = entryPackageFilePredicate(entry.fileName);
5042
- // Workspace-linked packages register BEFORE the tsc gate. Their files
5043
- // live at realpaths OUTSIDE node_modules (the monorepo-tool symlink
5044
- // shape), so nothing path-shaped marks them as npm surface — yet their
5045
- // shipped JS follows the same foreign-tsconfig rules as node_modules JS.
5046
- // The lazy
5047
- // registration inside the import-fence walk below runs AFTER errorsOf,
5048
- // too late for the gate, so one pass over the program's import edges
5049
- // registers them up front: every bare specifier any program file loads —
5050
- // import/export declarations, dynamic import("literal") (tsgo chases
5051
- // those into the program too; a CLI reaches its workspace sibling exactly
5052
- // that way), require("literal") — resolved with the own resolver,
5053
- // workspace answers recorded.
5112
+ /** Whether two resolutions name the same module file. Their spellings differ
5113
+ * routinely — a tsconfig `paths` answer keeps the project's spelling where
5114
+ * the npm resolver answers realpath'd — so the real paths decide. */
5115
+ function sameResolvedFile(a, b) {
5116
+ const normalize = (path) => path.replaceAll("\\", "/");
5117
+ if (normalize(a) === normalize(b))
5118
+ return true;
5119
+ return normalize(trackedRealpath(a) ?? a) === normalize(trackedRealpath(b) ?? b);
5120
+ }
5121
+ /** A program file TypeScript's checker pulled in from a package the build
5122
+ * does not compile — unselected node_modules JavaScript, or an unselected
5123
+ * workspace package's shipped JavaScript at a realpath outside node_modules
5124
+ * (the symlinked-install shape): Node never loads it as program source. */
5125
+ function unselectedPackageJsFilePredicate(entryFileName) {
5126
+ const entryPackageFile = entryPackageFilePredicate(entryFileName);
5127
+ return (file) => isJsSourceFileName(file) &&
5128
+ !entryPackageFile(file) &&
5129
+ npmStaticPackageOfPath(file) === null &&
5130
+ (isNodeModulesPath(file) || workspacePackageOfPath(file) !== null);
5131
+ }
5132
+ /** Workspace-linked packages register before the tsc gate. Their files live
5133
+ * at realpaths OUTSIDE node_modules (the monorepo-tool symlink shape), so
5134
+ * nothing path-shaped marks them as npm surface — yet their shipped JS
5135
+ * follows the same foreign-tsconfig rules as node_modules JS. The lazy
5136
+ * registration inside the import-fence walk registers them too, but too late
5137
+ * for the gate, so one pass over the program's import edges registers them up
5138
+ * front: every bare specifier any program file loads — import/export
5139
+ * declarations, dynamic import("literal") (tsgo chases those into the program
5140
+ * too; a CLI reaches its workspace sibling exactly that way),
5141
+ * require("literal") — resolved with the own resolver, workspace answers
5142
+ * recorded. Runs once per load, ahead of the gate and the walk. */
5143
+ function registerWorkspaceEdges(load) {
5144
+ if (load.workspaceProbed === true)
5145
+ return;
5146
+ load.workspaceProbed = true;
5147
+ const { program } = load;
5054
5148
  {
5055
5149
  const supportedBuiltins = new Set(SUPPORTED_NODE_MODULES);
5056
5150
  const probed = new Set();
@@ -5076,317 +5170,126 @@ function preflight7(load) {
5076
5170
  probe(sf.fileName, specifier);
5077
5171
  }
5078
5172
  }
5079
- const toPassthrough = (d) => {
5080
- const message = ts.flattenDiagnosticMessageText(d, "\n");
5081
- // File-less (global/options) diagnostics anchor at the entry with a
5082
- // zero span, exactly like the 5.9.3 lane's `d.start ?? 0` fallback.
5083
- const file = d.fileName ?? entry.fileName;
5084
- const start = d.fileName !== undefined ? d.pos : 0;
5085
- const end = d.fileName !== undefined ? d.end : 0;
5086
- const diag = tscPassthroughDiag(message, { file, start, end });
5087
- const hint = typeWorldHint(d, message, load);
5088
- if (hint !== null) {
5089
- diag.typeWorld = true;
5090
- diag.hint = hint;
5173
+ }
5174
+ function preflightStructure(load) {
5175
+ if (load.preflightStructure === undefined)
5176
+ load.preflightStructure = preflightStructure7(load);
5177
+ return load.preflightStructure;
5178
+ }
5179
+ function preflightStructure7(load) {
5180
+ const { program, entry } = load;
5181
+ // The walk's own diagnostics. The config diagnostics and the tsc gate are
5182
+ // preflightDiagnostics7's, which reports them ahead of these.
5183
+ const diags = [];
5184
+ const unselectedPackageJsFile = unselectedPackageJsFilePredicate(entry.fileName);
5185
+ // An explicit entry can itself live in an installed package. Its own
5186
+ // source files are program code, including relative barrels and sibling
5187
+ // modules; their location must not erase the module graph.
5188
+ // Match the full installed directory, not just the package name, and
5189
+ // exclude nested installations so dependencies keep their npm policy.
5190
+ const entryPackageFile = entryPackageFilePredicate(entry.fileName);
5191
+ // Preflight and lowering share this CheckerFacade. Claim executable
5192
+ // source files after workspace discovery and the tsc gate but before
5193
+ // structural preflight checker queries, so a miss cannot trigger the old
5194
+ // whole-file sweep (and eagerly fetch every dead body's answers). The
5195
+ // structure wave includes declaration headers and top-level code;
5196
+ // reachable bodies are added by lowering's worklists.
5197
+ const ambient = ambientDtsPath();
5198
+ const programFiles = program
5199
+ .getImplementationSourceFiles()
5200
+ .filter((sf) => sf.fileName !== ambient &&
5201
+ !sf.isDeclarationFile &&
5202
+ !sf.fileName.endsWith(".json") &&
5203
+ (!isNodeModulesPath(sf.fileName) ||
5204
+ entryPackageFile(sf.fileName) ||
5205
+ npmStaticPackageOfPath(sf.fileName) !== null) &&
5206
+ !unselectedPackageJsFile(sf.fileName));
5207
+ // Files reached only through `import type` / `export type … from` are
5208
+ // checker input, never program modules: Node does not load them, so
5209
+ // their imports and syntax must not fence the program.
5210
+ //
5211
+ // Reachability over-approximates: `callReferencesOf` and the reexport
5212
+ // planner count EVERY call with a leading string literal as a loading
5213
+ // edge, so a bare specifier that merely names a package — a model id
5214
+ // passed to a catalog helper, a settings key passed to `markModified` —
5215
+ // reaches npm resolution here. Whether this walk runs at all depends on
5216
+ // the program it is handed (it early-returns unless an erased reference
5217
+ // resolves, and the island rounds change the program), so classifying a
5218
+ // miss from it made package selection depend on program composition: the
5219
+ // same build could refuse a static package's entry as "did not join the
5220
+ // type-checked program" or compile it, run to run. Report nothing from
5221
+ // these edges; the walks that model real loads (import/export
5222
+ // declarations and `require()`/`import()` calls) own the offender
5223
+ // classification.
5224
+ const resolveRuntimeEdge = (sf, spec, resolutionKind) => resolveImport7(program, sf, spec, resolutionKind, false) ??
5225
+ npmStaticDepSf7(program, sf, spec, resolutionKind);
5226
+ const typeOnlyFiles = typeOnlyReachedFiles(program, entry, programFiles, () => [
5227
+ ...forkTargetPaths(program, program.getImplementationSourceFiles()),
5228
+ ...workerTargetPaths(program, program.getImplementationSourceFiles()),
5229
+ ], resolveRuntimeEdge);
5230
+ const runtimeFiles = typeOnlyFiles.size === 0 ? programFiles : programFiles.filter((sf) => !typeOnlyFiles.has(sf));
5231
+ const userFiles = npmStaticActive()
5232
+ ? planNpmStaticReexports(program, entry, runtimeFiles, [
5233
+ ...createRequireProgramRoots7(program),
5234
+ ...forkTargetPaths(program, program.getImplementationSourceFiles()),
5235
+ ...workerTargetPaths(program, program.getImplementationSourceFiles()),
5236
+ ], resolveRuntimeEdge)
5237
+ : runtimeFiles;
5238
+ program.getTypeChecker().prefetchSourceFileStructures(userFiles);
5239
+ // Unselected node_modules JS is not native program source even when
5240
+ // maxNodeModuleJsDepth pulled it into the checker (nodeModulesJsSuppressed).
5241
+ // Node stops at the nearest package.json even when it is malformed, and
5242
+ // an explicit CommonJS scope (or .cjs/.cts extension) disables ambiguous-
5243
+ // file syntax detection entirely. TypeScript's bundler checker models
5244
+ // neither loader rule, so restore them before any module-edge analysis:
5245
+ // one malformed-scope diagnostic per package file, and one pointed syntax
5246
+ // diagnostic per CommonJS source file.
5247
+ const invalidPackageConfigs = new Set();
5248
+ for (const sf of userFiles) {
5249
+ const invalidConfig = nearestInvalidPackageJsonPath(sf.fileName);
5250
+ if (invalidConfig !== null) {
5251
+ if (!invalidPackageConfigs.has(invalidConfig)) {
5252
+ invalidPackageConfigs.add(invalidConfig);
5253
+ diags.push(invalidPackageConfigDiag(invalidConfig, { file: sf.fileName, start: 0, end: 0 }));
5254
+ }
5255
+ continue;
5091
5256
  }
5092
- return diag;
5093
- };
5094
- /* TS7 checker change (not finding 5, same discipline): tsgo types a
5095
- * NAMESPACE import as the spec's non-callable module namespace object
5096
- * even when the module is declared with the callable `export =` shape —
5097
- * 5.9.3 bound the callable value directly, so `import * as a from
5098
- * "node:assert"; a(x)` typechecked there and draws TS2349 here. Those
5099
- * callable module objects are scriptc's OWN declared surface, and calls
5100
- * through the namespace binding are fenced per site by the lowering (the
5101
- * assert-fences fixture pins the wording), so tsgo's extra TS2349 on
5102
- * exactly those callees — an identifier that is a namespace-import
5103
- * binding of a supported builtin module — is suppressed to the 5.9.3
5104
- * verdict. Nothing else rides this: any other non-callable call keeps
5105
- * tsc's voice in both lanes. */
5106
- const builtinNamespaceNames = new Map();
5107
- const namespaceCalleeSuppressed = (p, d) => {
5108
- if (d.code !== 2349 || d.fileName === undefined)
5109
- return false;
5110
- let names = builtinNamespaceNames.get(d.fileName);
5111
- if (!names) {
5112
- names = new Set();
5113
- builtinNamespaceNames.set(d.fileName, names);
5114
- const sf = p.getSourceFile(d.fileName);
5115
- for (const stmt of sf?.statements?.nodes ?? []) {
5116
- if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier))
5117
- continue;
5118
- if (canonicalBuiltinModule(stmt.moduleSpecifier.text) === null)
5119
- continue;
5120
- const bindings = stmt.importClause?.namedBindings;
5121
- if (bindings && ts.isNamespaceImport(bindings))
5122
- names.add(bindings.name.text);
5257
+ if (!isNodeEsmFile7(sf, program)) {
5258
+ const marker = nodeEsmSyntaxMarker7(sf);
5259
+ if (marker !== null)
5260
+ diags.push(commonJsModuleSyntaxDiag(locOf7(marker)));
5261
+ }
5262
+ }
5263
+ const ambientModules = new Set(SUPPORTED_NODE_MODULES);
5264
+ // Ambient `declare module "name"` declarations anywhere in the program —
5265
+ // exact names and `*` patterns — so the import fence can say "type
5266
+ // surface only, no runtime module" instead of the generic package story.
5267
+ // Computed lazily: the scan only runs when a bare-import fence is about
5268
+ // to fire.
5269
+ let ambientModuleDecls = null;
5270
+ const ambientDeclared = (spec) => {
5271
+ if (ambientModuleDecls === null) {
5272
+ ambientModuleDecls = { names: new Set(), patterns: [] };
5273
+ for (const f of program.getSourceFiles()) {
5274
+ for (const s of f.statements.nodes) {
5275
+ if (!ts.isModuleDeclaration(s) || !ts.isStringLiteral(s.name))
5276
+ continue;
5277
+ const name = s.name.text;
5278
+ if (name.includes("*"))
5279
+ ambientModuleDecls.patterns.push(name);
5280
+ else
5281
+ ambientModuleDecls.names.add(name);
5282
+ }
5123
5283
  }
5124
5284
  }
5125
- if (names.size === 0)
5126
- return false;
5127
- const sf = p.getSourceFile(d.fileName);
5128
- return sf !== undefined && names.has(sf.text.slice(d.pos, d.end));
5129
- };
5130
- const npmStaticFileSuppressed = (d) => d.fileName !== undefined && npmStaticPackageOfPath(d.fileName) !== null;
5131
- const unselectedPackageJsFile = (file) => isJsSourceFileName(file) &&
5132
- !entryPackageFile(file) &&
5133
- npmStaticPackageOfPath(file) === null &&
5134
- (isNodeModulesPath(file) || workspacePackageOfPath(file) !== null);
5135
- const nodeModulesJsSuppressed = (d) => d.fileName !== undefined && unselectedPackageJsFile(d.fileName);
5136
- /* JSDoc TYPE positions in JS files are documentation Node never reads:
5137
- * a name-resolution failure THERE (2304/2552 — the pattern's utilities.js
5138
- * spells a mapped type over a @template name it never declared) types
5139
- * as the error-any and the per-site fences apply, same stance as the
5140
- * strictness families above. A 2300 duplicate-identifier PAIR formed by
5141
- * a @typedef and a same-named class/function is the same story — the
5142
- * typedef half sits inside the comment, and the code half is suppressed
5143
- * exactly when its partner (same file, same name) was comment-side, so
5144
- * a REAL duplicate declaration (both halves in code — Node's own
5145
- * SyntaxError) keeps tsc's voice. */
5146
- const insideBlockComment = (text, pos) => {
5147
- const open = text.lastIndexOf("/*", pos);
5148
- if (open < 0)
5149
- return false;
5150
- const close = text.indexOf("*/", open + 2);
5151
- return close === -1 || close >= pos;
5152
- };
5153
- const jsdocTypeSuppressed = (p, d, commentDup) => {
5154
- if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
5155
- return false;
5156
- if (d.code !== 2304 && d.code !== 2552 && d.code !== 2300 && d.code !== 1003)
5157
- return false;
5158
- if (d.pos === undefined)
5159
- return false;
5160
- const sf = p.getSourceFile(d.fileName);
5161
- if (!sf)
5162
- return false;
5163
- if (insideBlockComment(sf.text, d.pos))
5285
+ if (ambientModuleDecls.names.has(spec))
5164
5286
  return true;
5165
- return d.code === 2300 && commentDup.has(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
5166
- };
5167
- /* `typeof window` / `typeof self` in a JavaScript file: the operand of
5168
- * typeof may name a global nothing declares (Node answers "undefined"
5169
- * and never throws), the feature-detection idiom every isomorphic
5170
- * package uses, and the guarded uses of that name (`typeof window < "u"
5171
- * ? window : …`) are code Node never runs. A name the file feature-tests
5172
- * this way is therefore not a type error in JavaScript; a reached use
5173
- * still meets the lowering's located refusal. TypeScript files keep the
5174
- * error and its hint. */
5175
- const typeofTestedNameSuppressed = (p, d) => {
5176
- if (d.code !== 2304 && d.code !== 2552 && d.code !== 2584)
5177
- return false;
5178
- if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
5179
- return false;
5180
- if (d.pos === undefined || d.end === undefined)
5181
- return false;
5182
- const sf = p.getSourceFile(d.fileName);
5183
- if (!sf)
5184
- return false;
5185
- const name = sf.text.slice(d.pos, d.end);
5186
- if (!/^[A-Za-z_$][\w$]*$/.test(name))
5187
- return false;
5188
- return new RegExp(`\\btypeof\\s*\\(?\\s*${name.replace(/\$/g, "\\$")}(?![\\w$])`).test(sf.text);
5189
- };
5190
- // A `return` at the top level of a CommonJS module (TS1108): Node runs
5191
- // the module as a function body, so the return ends the module's
5192
- // evaluation. ES modules and TypeScript keep the error.
5193
- const cjsTopLevelReturnSuppressed = (p, d) => {
5194
- if (d.code !== 1108 || d.fileName === undefined || !isJsSourceFileName(d.fileName))
5195
- return false;
5196
- const sf = p.getSourceFile(d.fileName);
5197
- return sf !== undefined && isCjsJsFile7(sf, p);
5198
- };
5199
- const workspaceImplicitAnySuppressed = (p, d) => {
5200
- if (d.code !== 7016 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
5201
- return false;
5202
- const sf = p.getSourceFile(d.fileName);
5203
- if (!sf)
5204
- return false;
5205
- const spec = sf.text.slice(d.pos, d.end).replace(/^['"]|['"]$/g, "");
5206
- const prefix = spec.startsWith("@")
5207
- ? spec.split("/").slice(0, 2).join("/")
5208
- : spec.split("/")[0];
5209
- return isWorkspacePackageName(prefix);
5210
- };
5211
- // A JavaScript file that TypeScript checks keeps the type errors that
5212
- // protect its JSDoc types: a value of another type reaching a typed slot,
5213
- // a call with the wrong arity, and a subclass member that does not
5214
- // match its base.
5215
- const projectCheckJs = load.typeWorld?.projectCheckJs ?? false;
5216
- const enforcedInCheckedJs = (p, d) => {
5217
- if (!CHECKED_JS_ENFORCED_CODES.has(d.code) || d.fileName === undefined)
5218
- return false;
5219
- const sf = p.getSourceFile(d.fileName);
5220
- return sf !== undefined && isCheckedJsSourceFile(sf, projectCheckJs);
5221
- };
5222
- // keptErrors drops every diagnostic of these files: the gate does not ask
5223
- // the checker for them.
5224
- const diagnosticsKept = (fileName) => npmStaticPackageOfPath(fileName) === null &&
5225
- !unselectedPackageJsFile(fileName) &&
5226
- !isPackageShimFile(fileName);
5227
- const errorsOf = (p) => keptErrors(p, ts.getPreEmitDiagnostics(p, diagnosticsKept));
5228
- const keptErrors = (p, all) => {
5229
- // First pass: every comment-side 2300's (file, name) — the partners
5230
- // the second pass forgives.
5231
- const commentDup = new Set();
5232
- for (const d of all) {
5233
- if (d.code !== 2300 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
5234
- continue;
5235
- if (!isJsSourceFileName(d.fileName))
5236
- continue;
5237
- const sf = p.getSourceFile(d.fileName);
5238
- if (sf && insideBlockComment(sf.text, d.pos))
5239
- commentDup.add(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
5240
- }
5241
- return all.filter((d) => d.category === ts.DiagnosticCategory.Error &&
5242
- (!suppressedJsStrictness7(d) || enforcedInCheckedJs(p, d)) &&
5243
- !npmStaticFileSuppressed(d) &&
5244
- !nodeModulesJsSuppressed(d) &&
5245
- (d.fileName === undefined || !isPackageShimFile(d.fileName)) &&
5246
- !namespaceCalleeSuppressed(p, d) &&
5247
- !inferredJsDiagnosticSuppressed(p, d) &&
5248
- !isNpmStaticSubclassArgument(p, d) &&
5249
- !workspaceImplicitAnySuppressed(p, d) &&
5250
- !typeofTestedNameSuppressed(p, d) &&
5251
- !cjsTopLevelReturnSuppressed(p, d) &&
5252
- !jsdocTypeSuppressed(p, d, commentDup));
5253
- };
5254
- // The tsc gate, with a second chance: the LOWERING world's checker
5255
- // includes the divergence overrides (JSON.parse(): unknown, the Promise
5256
- // executor shape, ...), which are TIGHTER than the standard lib — a
5257
- // project that typechecks clean under its own tsc can still error here
5258
- // (any-typed JSON.parse results, most commonly). Those errors are OURS,
5259
- // not the project's, so they must not fail preflight: when the lowering
5260
- // world has errors, the PROJECT world (same program without the override
5261
- // declarations) is built and consulted. Clean there → preflight passes
5262
- // and the override-affected sites meet the lowerer's honest fences
5263
- // instead (the SC1100 checked-cast family). Dirty there → the project-
5264
- // world errors are the ones reported: they are reproducible with the
5265
- // project's own tsc, which is what "fix type errors first" asks for.
5266
- // With JSX sources, the program over the original text answers the tsc
5267
- // gate; its positions move into the rewritten text the program holds.
5268
- // Errors only the rewritten text has come from the calls the JSX lowers
5269
- // to (a factory whose signature does not accept them).
5270
- const tscWorld = load.tscWorld;
5271
- const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
5272
- if (tscErrors.length > 0) {
5273
- const world = tscWorld === undefined || tscWorld.declWorldFallback === true
5274
- ? load.projectWorld()
5275
- : (tscWorld.projectWorld ?? tscWorld.program);
5276
- for (const d of errorsOf(world)) {
5277
- const diag = toPassthrough(d);
5278
- const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
5279
- if (lowered !== undefined) {
5280
- diag.loc = {
5281
- ...diag.loc,
5282
- start: lowered.rewrittenPosition(diag.loc.start, false),
5283
- end: lowered.rewrittenPosition(diag.loc.end, true),
5284
- };
5285
- }
5286
- diags.push(diag);
5287
- }
5288
- }
5289
- else if (load.jsxSources !== undefined) {
5290
- for (const file of load.jsxSources.keys()) {
5291
- const sf = program.getSourceFile(file);
5292
- if (sf === undefined)
5293
- continue;
5294
- const own = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
5295
- for (const d of keptErrors(program, own)) {
5296
- const diag = toPassthrough(d);
5297
- diag.message = `${diag.message} (in the call this JSX lowers to)`;
5298
- diags.push(diag);
5299
- }
5300
- }
5301
- }
5302
- // Preflight and lowering share this CheckerFacade. Claim executable
5303
- // source files after workspace discovery and the tsc gate but before
5304
- // structural preflight checker queries, so a miss cannot trigger the old
5305
- // whole-file sweep (and eagerly fetch every dead body's answers). The
5306
- // structure wave includes declaration headers and top-level code;
5307
- // reachable bodies are added by lowering's worklists.
5308
- const ambient = ambientDtsPath();
5309
- const programFiles = program
5310
- .getImplementationSourceFiles()
5311
- .filter((sf) => sf.fileName !== ambient &&
5312
- !sf.isDeclarationFile &&
5313
- !sf.fileName.endsWith(".json") &&
5314
- (!isNodeModulesPath(sf.fileName) ||
5315
- entryPackageFile(sf.fileName) ||
5316
- npmStaticPackageOfPath(sf.fileName) !== null) &&
5317
- !unselectedPackageJsFile(sf.fileName));
5318
- // Files reached only through `import type` / `export type … from` are
5319
- // checker input, never program modules: Node does not load them, so
5320
- // their imports and syntax must not fence the program.
5321
- const resolveRuntimeEdge = (sf, spec, resolutionKind) => resolveImport7(program, sf, spec, resolutionKind) ??
5322
- npmStaticDepSf7(program, sf, spec, resolutionKind);
5323
- const typeOnlyFiles = typeOnlyReachedFiles(program, entry, programFiles, () => [
5324
- ...forkTargetPaths(program, program.getImplementationSourceFiles()),
5325
- ...workerTargetPaths(program, program.getImplementationSourceFiles()),
5326
- ], resolveRuntimeEdge);
5327
- const runtimeFiles = typeOnlyFiles.size === 0 ? programFiles : programFiles.filter((sf) => !typeOnlyFiles.has(sf));
5328
- const userFiles = npmStaticActive()
5329
- ? planNpmStaticReexports(program, entry, runtimeFiles, [
5330
- ...createRequireProgramRoots7(program),
5331
- ...forkTargetPaths(program, program.getImplementationSourceFiles()),
5332
- ...workerTargetPaths(program, program.getImplementationSourceFiles()),
5333
- ], resolveRuntimeEdge)
5334
- : runtimeFiles;
5335
- program.getTypeChecker().prefetchSourceFileStructures(userFiles);
5336
- // Unselected node_modules JS is not native program source even when
5337
- // maxNodeModuleJsDepth pulled it into the checker (nodeModulesJsSuppressed).
5338
- // Node stops at the nearest package.json even when it is malformed, and
5339
- // an explicit CommonJS scope (or .cjs/.cts extension) disables ambiguous-
5340
- // file syntax detection entirely. TypeScript's bundler checker models
5341
- // neither loader rule, so restore them before any module-edge analysis:
5342
- // one malformed-scope diagnostic per package file, and one pointed syntax
5343
- // diagnostic per CommonJS source file.
5344
- const invalidPackageConfigs = new Set();
5345
- for (const sf of userFiles) {
5346
- const invalidConfig = nearestInvalidPackageJsonPath(sf.fileName);
5347
- if (invalidConfig !== null) {
5348
- if (!invalidPackageConfigs.has(invalidConfig)) {
5349
- invalidPackageConfigs.add(invalidConfig);
5350
- diags.push(invalidPackageConfigDiag(invalidConfig, { file: sf.fileName, start: 0, end: 0 }));
5351
- }
5352
- continue;
5353
- }
5354
- if (!isNodeEsmFile7(sf, program)) {
5355
- const marker = nodeEsmSyntaxMarker7(sf);
5356
- if (marker !== null)
5357
- diags.push(commonJsModuleSyntaxDiag(locOf7(marker)));
5358
- }
5359
- }
5360
- const ambientModules = new Set(SUPPORTED_NODE_MODULES);
5361
- // Ambient `declare module "name"` declarations anywhere in the program —
5362
- // exact names and `*` patterns — so the import fence can say "type
5363
- // surface only, no runtime module" instead of the generic package story.
5364
- // Computed lazily: the scan only runs when a bare-import fence is about
5365
- // to fire.
5366
- let ambientModuleDecls = null;
5367
- const ambientDeclared = (spec) => {
5368
- if (ambientModuleDecls === null) {
5369
- ambientModuleDecls = { names: new Set(), patterns: [] };
5370
- for (const f of program.getSourceFiles()) {
5371
- for (const s of f.statements.nodes) {
5372
- if (!ts.isModuleDeclaration(s) || !ts.isStringLiteral(s.name))
5373
- continue;
5374
- const name = s.name.text;
5375
- if (name.includes("*"))
5376
- ambientModuleDecls.patterns.push(name);
5377
- else
5378
- ambientModuleDecls.names.add(name);
5379
- }
5380
- }
5381
- }
5382
- if (ambientModuleDecls.names.has(spec))
5383
- return true;
5384
- return ambientModuleDecls.patterns.some((p) => {
5385
- const star = p.indexOf("*");
5386
- return (spec.length >= p.length - 1 &&
5387
- spec.startsWith(p.slice(0, star)) &&
5388
- spec.endsWith(p.slice(star + 1)));
5389
- });
5287
+ return ambientModuleDecls.patterns.some((p) => {
5288
+ const star = p.indexOf("*");
5289
+ return (spec.length >= p.length - 1 &&
5290
+ spec.startsWith(p.slice(0, star)) &&
5291
+ spec.endsWith(p.slice(star + 1)));
5292
+ });
5390
5293
  };
5391
5294
  // Module edges. An edge that closes a cycle is judged by the shared
5392
5295
  // admission engine (makeCycleAdmission): admissible when nothing can
@@ -5568,12 +5471,30 @@ function preflight7(load) {
5568
5471
  // Project modules win before npm fallback: this is the source graph
5569
5472
  // tsgo type-checked for tsconfig paths, package imports/self-references,
5570
5473
  // and provenance entries. Ordinary packages still answer null here.
5571
- const projDep = isBare ? resolveImport7(program, sf, spec) : null;
5572
- // "#" specifiers can never name an npm package — they are the
5573
- // imports-field family, resolved by the project arm above.
5574
- const npm = isBare && projDep === null && !spec.startsWith("#")
5575
- ? resolveNpmImport7(sf.fileName, spec)
5576
- : null;
5474
+ const projectAnswer = isBare ? resolveImport7(program, sf, spec) : null;
5475
+ let projDep = projectAnswer;
5476
+ let npm = null;
5477
+ if (isBare && !spec.startsWith("#")) {
5478
+ // A tsconfig `paths` target can name an installed package's directory
5479
+ // (pi maps "typebox": ["./node_modules/typebox"]): its declarations
5480
+ // are the package's own, so Node resolves the same specifier to the
5481
+ // same answer and the import is an npm import after all. The npm arm
5482
+ // below owns it then — its runtime refusal, npm-static membership and
5483
+ // island policy included. A mapping whose answer the npm resolver does
5484
+ // not reproduce stays a project import (and its SC1010).
5485
+ const installed = projectAnswer !== null &&
5486
+ projectAnswer.isDeclarationFile &&
5487
+ isNodeModulesPath(projectAnswer.fileName)
5488
+ ? resolveNpmImport7(sf.fileName, spec)
5489
+ : null;
5490
+ if (installed !== null && sameResolvedFile(installed.typesFile, projectAnswer.fileName)) {
5491
+ projDep = null;
5492
+ npm = installed;
5493
+ }
5494
+ else if (projectAnswer === null) {
5495
+ npm = resolveNpmImport7(sf.fileName, spec);
5496
+ }
5497
+ }
5577
5498
  if (npm && isNodeTypesPath(npm.typesFile)) {
5578
5499
  diags.push(unsupportedDiag("SC1010", locOf7(stmt), unsupportedModuleFeatureOf(spec)));
5579
5500
  continue;
@@ -6086,11 +6007,6 @@ function preflight7(load) {
6086
6007
  }
6087
6008
  };
6088
6009
  visit(entry);
6089
- // ECMAScript's sloppy-mode WRITE to an undeclared name, which the JS
6090
- // relaxation above admits for READS (plan D-2): refused by name, with the
6091
- // island route in the text (SC1091).
6092
- for (const d of jsUndeclaredWriteDiags(program, order))
6093
- diags.push(d);
6094
6010
  // The startup crash Node's RESOLUTION phase reports: modules resolve
6095
6011
  // their request specifiers in source order, children linking depth-first
6096
6012
  // as each resolves (ModuleJob.syncLink) — a preorder walk over the
@@ -6101,6 +6017,7 @@ function preflight7(load) {
6101
6017
  // Node's fetch/resolve phase runs before instantiate.
6102
6018
  let resolveCrash = null;
6103
6019
  const dynamicImportRejections = new Map();
6020
+ const fallbacks = [];
6104
6021
  {
6105
6022
  const seen = new Set();
6106
6023
  const walk = (sf) => {
@@ -6173,32 +6090,388 @@ function preflight7(load) {
6173
6090
  // preflight: when any other diagnostic already fails the build, every
6174
6091
  // refusal keeps its compile-fence fallback instead — the report names
6175
6092
  // each import's story, so edges whose crash will never compile still
6176
- // get a diagnostic. (No reachable refusal → same: fallbacks only.)
6177
- if (resolveCrash === null || diags.length > 0) {
6178
- resolveCrash = null;
6179
- for (const [sf, cands] of refusals) {
6180
- if (covered.has(sf) && !startup.has(sf))
6181
- continue;
6182
- for (const c of cands)
6183
- diags.push(c.fallback);
6184
- }
6093
+ // get a diagnostic. (No reachable refusal → same: fallbacks only.) The
6094
+ // "otherwise pass" half of that question is preflightDiagnostics7's:
6095
+ // it alone sees the tsc gate's diagnostics, so it reports `fallbacks`.
6096
+ for (const [sf, cands] of refusals) {
6097
+ if (covered.has(sf) && !startup.has(sf))
6098
+ continue;
6099
+ for (const c of cands)
6100
+ fallbacks.push(c.fallback);
6185
6101
  }
6186
6102
  }
6187
- const linkCrash = resolveCrash !== null
6103
+ return {
6104
+ order,
6105
+ moduleEdges: edges,
6106
+ dynamicImportRejections,
6107
+ inlineRequireCycleCalls,
6108
+ diags,
6109
+ resolveCrash,
6110
+ fallbacks,
6111
+ };
6112
+ }
6113
+ /** The whole preflight for one load: the tsc gate, the module graph walk and
6114
+ * every diagnostic they report, in report order. The structure is memoized,
6115
+ * so a caller that asked for the order first (checkModuleOrder) pays for the
6116
+ * walk once. */
6117
+ function preflight7(load) {
6118
+ registerWorkspaceEdges(load);
6119
+ const gate = preflightGate7(load);
6120
+ const structure = preflightStructure(load);
6121
+ const { diags, startupCrash } = preflightDiagnostics7(load, structure, gate.diags);
6122
+ return {
6123
+ diags,
6124
+ moduleOrder: structure.order,
6125
+ startupCrash,
6126
+ inlineRequireCycleCalls: structure.inlineRequireCycleCalls,
6127
+ moduleEdges: structure.moduleEdges,
6128
+ dynamicImportRejections: structure.dynamicImportRejections,
6129
+ admittedOpinions: gate.admittedOpinions,
6130
+ };
6131
+ }
6132
+ /** The diagnostics half of preflight: the tsc gate ahead of the walk's own
6133
+ * diagnostics, then the passes that judge the completed module order. The
6134
+ * tsc gate runs first on every load whose order was not requested on its
6135
+ * own, exactly as it did inside the single pass. */
6136
+ function preflightDiagnostics7(load, structure, gate) {
6137
+ const { program, entry } = load;
6138
+ const order = structure.order;
6139
+ const diags = [...load.configDiags];
6140
+ for (const d of gate)
6141
+ diags.push(d);
6142
+ for (const d of structure.diags)
6143
+ diags.push(d);
6144
+ // ECMAScript's sloppy-mode WRITE to an undeclared name, which the JS
6145
+ // relaxation above admits for READS (plan D-2): refused by name, with the
6146
+ // island route in the text (SC1091).
6147
+ for (const d of jsUndeclaredWriteDiags(program, order))
6148
+ diags.push(d);
6149
+ // The crash channel engages only when nothing else fails preflight.
6150
+ let startupCrash = structure.resolveCrash;
6151
+ if (startupCrash === null || diags.length > 0) {
6152
+ startupCrash = null;
6153
+ for (const d of structure.fallbacks)
6154
+ diags.push(d);
6155
+ }
6156
+ const linkCrash = startupCrash !== null
6188
6157
  ? null
6189
6158
  : earlierLinkCrash(order, cjsNamedImportLinkCheck(program, entry, order, diags), esmNamedImportLinkCheck(program, entry, order, diags));
6190
6159
  // ECMAScript early errors the TypeScript checker does not model (plan
6191
6160
  // §7.7 D-4): a JavaScript source the spec makes a SyntaxError fails here,
6192
6161
  // before any lowering, exactly where a tsc parse error fails.
6193
6162
  diags.push(...earlyErrorDiagnostics7(order, (sf) => isNodeEsmFile7(sf, program)));
6194
- return {
6195
- diags,
6196
- moduleOrder: order,
6197
- startupCrash: resolveCrash ?? linkCrash,
6198
- inlineRequireCycleCalls,
6199
- moduleEdges: edges,
6200
- dynamicImportRejections,
6163
+ return { diags, startupCrash: startupCrash ?? linkCrash };
6164
+ }
6165
+ function preflightGate7(load) {
6166
+ const { program, entry } = load;
6167
+ const diags = [];
6168
+ const unselectedPackageJsFile = unselectedPackageJsFilePredicate(entry.fileName);
6169
+ const toPassthrough = (d) => {
6170
+ const message = ts.flattenDiagnosticMessageText(d, "\n");
6171
+ // File-less (global/options) diagnostics anchor at the entry with a
6172
+ // zero span, exactly like the 5.9.3 lane's `d.start ?? 0` fallback.
6173
+ const file = d.fileName ?? entry.fileName;
6174
+ const start = d.fileName !== undefined ? d.pos : 0;
6175
+ const end = d.fileName !== undefined ? d.end : 0;
6176
+ // A JavaScript source's `refuse`/`rewrite` code names the construct
6177
+ // scriptc does not lower (tsc-codes.ts): the user sees what is missing
6178
+ // instead of TypeScript's opinion about legal JavaScript.
6179
+ const triaged = d.fileName !== undefined && isJsSourceFileName(d.fileName) ? jsTscCodeTriage(d.code) : null;
6180
+ if (triaged?.action === "refuse" || triaged?.action === "rewrite") {
6181
+ const diag = unsupportedDiag("SC1090", { file, start, end }, triaged.feature, `${triaged.hint} (TypeScript reports TS${d.code} here.)`);
6182
+ return diag;
6183
+ }
6184
+ const diag = tscPassthroughDiag(message, { file, start, end });
6185
+ const hint = typeWorldHint(d, message, load);
6186
+ if (hint !== null) {
6187
+ diag.typeWorld = true;
6188
+ diag.hint = hint;
6189
+ }
6190
+ return diag;
6191
+ };
6192
+ /* TS7 checker change (not finding 5, same discipline): tsgo types a
6193
+ * NAMESPACE import as the spec's non-callable module namespace object
6194
+ * even when the module is declared with the callable `export =` shape —
6195
+ * 5.9.3 bound the callable value directly, so `import * as a from
6196
+ * "node:assert"; a(x)` typechecked there and draws TS2349 here. Those
6197
+ * callable module objects are scriptc's OWN declared surface, and calls
6198
+ * through the namespace binding are fenced per site by the lowering (the
6199
+ * assert-fences fixture pins the wording), so tsgo's extra TS2349 on
6200
+ * exactly those callees — an identifier that is a namespace-import
6201
+ * binding of a supported builtin module — is suppressed to the 5.9.3
6202
+ * verdict. Nothing else rides this: any other non-callable call keeps
6203
+ * tsc's voice in both lanes. */
6204
+ const builtinNamespaceNames = new Map();
6205
+ const namespaceCalleeSuppressed = (p, d) => {
6206
+ if (d.code !== 2349 || d.fileName === undefined)
6207
+ return false;
6208
+ let names = builtinNamespaceNames.get(d.fileName);
6209
+ if (!names) {
6210
+ names = new Set();
6211
+ builtinNamespaceNames.set(d.fileName, names);
6212
+ const sf = p.getSourceFile(d.fileName);
6213
+ for (const stmt of sf?.statements?.nodes ?? []) {
6214
+ if (!ts.isImportDeclaration(stmt) || !ts.isStringLiteral(stmt.moduleSpecifier))
6215
+ continue;
6216
+ if (canonicalBuiltinModule(stmt.moduleSpecifier.text) === null)
6217
+ continue;
6218
+ const bindings = stmt.importClause?.namedBindings;
6219
+ if (bindings && ts.isNamespaceImport(bindings))
6220
+ names.add(bindings.name.text);
6221
+ }
6222
+ }
6223
+ if (names.size === 0)
6224
+ return false;
6225
+ const sf = p.getSourceFile(d.fileName);
6226
+ return sf !== undefined && names.has(sf.text.slice(d.pos, d.end));
6227
+ };
6228
+ const npmStaticFileSuppressed = (d) => d.fileName !== undefined && npmStaticPackageOfPath(d.fileName) !== null;
6229
+ const nodeModulesJsSuppressed = (d) => d.fileName !== undefined && unselectedPackageJsFile(d.fileName);
6230
+ /* JSDoc TYPE positions in JS files are documentation Node never reads:
6231
+ * a name-resolution failure THERE (2304/2552 — the pattern's utilities.js
6232
+ * spells a mapped type over a @template name it never declared) types
6233
+ * as the error-any and the per-site fences apply, same stance as the
6234
+ * strictness families above. A 2300 duplicate-identifier PAIR formed by
6235
+ * a @typedef and a same-named class/function is the same story — the
6236
+ * typedef half sits inside the comment, and the code half is suppressed
6237
+ * exactly when its partner (same file, same name) was comment-side, so
6238
+ * a REAL duplicate declaration (both halves in code — Node's own
6239
+ * SyntaxError) keeps tsc's voice. */
6240
+ const insideBlockComment = (text, pos) => {
6241
+ const open = text.lastIndexOf("/*", pos);
6242
+ if (open < 0)
6243
+ return false;
6244
+ const close = text.indexOf("*/", open + 2);
6245
+ return close === -1 || close >= pos;
6246
+ };
6247
+ const jsdocTypeSuppressed = (p, d, commentDup) => {
6248
+ if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
6249
+ return false;
6250
+ if (d.code !== 2304 && d.code !== 2552 && d.code !== 2300 && d.code !== 1003)
6251
+ return false;
6252
+ if (d.pos === undefined)
6253
+ return false;
6254
+ const sf = p.getSourceFile(d.fileName);
6255
+ if (!sf)
6256
+ return false;
6257
+ if (insideBlockComment(sf.text, d.pos))
6258
+ return true;
6259
+ return d.code === 2300 && commentDup.has(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
6260
+ };
6261
+ /* `typeof window` / `typeof self` in a JavaScript file: the operand of
6262
+ * typeof may name a global nothing declares (Node answers "undefined"
6263
+ * and never throws), the feature-detection idiom every isomorphic
6264
+ * package uses, and the guarded uses of that name (`typeof window < "u"
6265
+ * ? window : …`) are code Node never runs. A name the file feature-tests
6266
+ * this way is therefore not a type error in JavaScript; a reached use
6267
+ * still meets the lowering's located refusal. TypeScript files keep the
6268
+ * error and its hint. */
6269
+ const typeofTestedNameSuppressed = (p, d) => {
6270
+ if (d.code !== 2304 && d.code !== 2552 && d.code !== 2584)
6271
+ return false;
6272
+ if (d.fileName === undefined || !isJsSourceFileName(d.fileName))
6273
+ return false;
6274
+ if (d.pos === undefined || d.end === undefined)
6275
+ return false;
6276
+ const sf = p.getSourceFile(d.fileName);
6277
+ if (!sf)
6278
+ return false;
6279
+ const name = sf.text.slice(d.pos, d.end);
6280
+ if (!/^[A-Za-z_$][\w$]*$/.test(name))
6281
+ return false;
6282
+ return new RegExp(`\\btypeof\\s*\\(?\\s*${name.replace(/\$/g, "\\$")}(?![\\w$])`).test(sf.text);
6283
+ };
6284
+ // A `return` at the top level of a CommonJS module (TS1108): Node runs
6285
+ // the module as a function body, so the return ends the module's
6286
+ // evaluation. ES modules and TypeScript keep the error.
6287
+ const cjsTopLevelReturnSuppressed = (p, d) => {
6288
+ if (d.code !== 1108 || d.fileName === undefined || !isJsSourceFileName(d.fileName))
6289
+ return false;
6290
+ const sf = p.getSourceFile(d.fileName);
6291
+ return sf !== undefined && isCjsJsFile7(sf, p);
6292
+ };
6293
+ const workspaceImplicitAnySuppressed = (p, d) => {
6294
+ if (d.code !== 7016 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
6295
+ return false;
6296
+ const sf = p.getSourceFile(d.fileName);
6297
+ if (!sf)
6298
+ return false;
6299
+ const spec = sf.text.slice(d.pos, d.end).replace(/^['"]|['"]$/g, "");
6300
+ const prefix = spec.startsWith("@")
6301
+ ? spec.split("/").slice(0, 2).join("/")
6302
+ : spec.split("/")[0];
6303
+ return isWorkspacePackageName(prefix);
6304
+ };
6305
+ // A JavaScript file that TypeScript checks keeps the type errors that
6306
+ // protect its JSDoc types: a value of another type reaching a typed slot,
6307
+ // a call with the wrong arity, and a subclass member that does not
6308
+ // match its base (the rows that say `checkedJs: "enforce"` in
6309
+ // JS_OPINIONS).
6310
+ const projectCheckJs = load.typeWorld?.projectCheckJs ?? false;
6311
+ // The opinion sites this preflight admits (tsc-codes.ts, JS_OPINIONS),
6312
+ // deduped across the worlds the gate consults (the lowering world, the
6313
+ // project world, the JSX text). The lowering asks opinionAt about one of
6314
+ // them; a view's lowering path is gated on the record, never on syntax.
6315
+ const admittedOpinions = new Map();
6316
+ const recordAdmittedOpinion = (site) => {
6317
+ admittedOpinions.set(`${site.file}\0${site.pos}\0${site.end}\0${site.code}`, site);
6318
+ };
6319
+ // A diagnostic's span is an offset into the text of the program that
6320
+ // answered it. With JSX sources the gate's worlds hold the files as
6321
+ // written, while the lowering asks opinionAt about nodes of `program`,
6322
+ // which carries the rewritten text; an original offset recorded as a site
6323
+ // would name an unrelated node wherever a rewrite moved the text. The span
6324
+ // moves into that text exactly as a reported diagnostic's location does
6325
+ // below: copied text keeps its offset, a span inside JSX maps to the call
6326
+ // it lowered to.
6327
+ const admittedSite = (p, site) => {
6328
+ if (p === program)
6329
+ return site;
6330
+ const lowered = load.jsxSources?.get(site.file);
6331
+ if (lowered === undefined)
6332
+ return site;
6333
+ return {
6334
+ ...site,
6335
+ pos: lowered.rewrittenPosition(site.pos, false),
6336
+ end: lowered.rewrittenPosition(site.end, true),
6337
+ };
6338
+ };
6339
+ // keptErrors drops every diagnostic of these files: the gate does not ask
6340
+ // the checker for them.
6341
+ const diagnosticsKept = (fileName) => npmStaticPackageOfPath(fileName) === null &&
6342
+ !unselectedPackageJsFile(fileName) &&
6343
+ !isPackageShimFile(fileName);
6344
+ const errorsOf = (p) => keptErrors(p, ts.getPreEmitDiagnostics(p, diagnosticsKept));
6345
+ const keptErrors = (p, all) => {
6346
+ // First pass: every comment-side 2300's (file, name) — the partners
6347
+ // the second pass forgives.
6348
+ const commentDup = new Set();
6349
+ for (const d of all) {
6350
+ if (d.code !== 2300 || d.fileName === undefined || d.pos === undefined || d.end === undefined)
6351
+ continue;
6352
+ if (!isJsSourceFileName(d.fileName))
6353
+ continue;
6354
+ const sf = p.getSourceFile(d.fileName);
6355
+ if (sf && insideBlockComment(sf.text, d.pos))
6356
+ commentDup.add(`${d.fileName}:${sf.text.slice(d.pos, d.end)}`);
6357
+ }
6358
+ // The syntactic diagnostics of a JS file, asked for only when a
6359
+ // diagnostic names a code an opinion row covers.
6360
+ const syntactic = new Map();
6361
+ const syntacticOf = (sf) => {
6362
+ let list = syntactic.get(sf.fileName);
6363
+ if (list === undefined) {
6364
+ list = p.getSyntacticDiagnostics(sf);
6365
+ syntactic.set(sf.fileName, list);
6366
+ }
6367
+ return list;
6368
+ };
6369
+ // The older filters that answer from the file name, the source text or
6370
+ // the syntax alone. The recording pass below uses this subset: the two
6371
+ // filters that ask the CHECKER a question
6372
+ // (inferredJsDiagnosticSuppressed, isNpmStaticSubclassArgument) are
6373
+ // deliberately not consulted for an admitted diagnostic. Before this
6374
+ // table, an admitted diagnostic was dropped before the chain reached
6375
+ // them, so asking now would add a checker query a program's compile
6376
+ // never made — and tsgo answers the query on a destructuring pattern
6377
+ // with a panic ("Value is not an instance of 'TupleType'"), which is how
6378
+ // this slice's Test262 replay first failed. The kept path still consults
6379
+ // every filter, in the order it always did.
6380
+ const keptApartFromOpinionTextually = (d) => !npmStaticFileSuppressed(d) &&
6381
+ !nodeModulesJsSuppressed(d) &&
6382
+ (d.fileName === undefined || !isPackageShimFile(d.fileName)) &&
6383
+ !namespaceCalleeSuppressed(p, d) &&
6384
+ !workspaceImplicitAnySuppressed(p, d) &&
6385
+ !typeofTestedNameSuppressed(p, d) &&
6386
+ !cjsTopLevelReturnSuppressed(p, d) &&
6387
+ !jsdocTypeSuppressed(p, d, commentDup);
6388
+ // Every filter except the opinion admission, in its historical order.
6389
+ const keptApartFromOpinion = (d) => keptApartFromOpinionTextually(d) &&
6390
+ !inferredJsDiagnosticSuppressed(p, d) &&
6391
+ !isNpmStaticSubclassArgument(p, d);
6392
+ const admitted = [];
6393
+ const kept = all.filter((d) => {
6394
+ if (d.category !== ts.DiagnosticCategory.Error)
6395
+ return false;
6396
+ // The 8xxx range is TypeScript's JSDoc-specific diagnostic family
6397
+ // (malformed tags, signature/tag mismatches): comment semantics with no
6398
+ // runtime meaning in a JS file, and no lowering view to record.
6399
+ if (d.fileName !== undefined &&
6400
+ isJsSourceFileName(d.fileName) &&
6401
+ d.code >= 8000 &&
6402
+ d.code <= 8999)
6403
+ return false;
6404
+ const opinion = jsOpinionOf7(p, d, projectCheckJs, syntacticOf);
6405
+ if (opinion !== null) {
6406
+ admitted.push({ d, opinion });
6407
+ return false;
6408
+ }
6409
+ return keptApartFromOpinion(d);
6410
+ });
6411
+ for (const { d, opinion } of admitted) {
6412
+ // No span, no site: nothing a view's lowering could be gated on.
6413
+ if (d.fileName === undefined || d.pos === undefined || d.end === undefined)
6414
+ continue;
6415
+ if (keptApartFromOpinionTextually(d))
6416
+ recordAdmittedOpinion(admittedSite(p, {
6417
+ file: d.fileName,
6418
+ pos: d.pos,
6419
+ end: d.end,
6420
+ code: d.code,
6421
+ view: opinion.view,
6422
+ }));
6423
+ }
6424
+ return kept;
6201
6425
  };
6426
+ // The tsc gate, with a second chance: the LOWERING world's checker
6427
+ // includes the divergence overrides (JSON.parse(): unknown, the Promise
6428
+ // executor shape, ...), which are TIGHTER than the standard lib — a
6429
+ // project that typechecks clean under its own tsc can still error here
6430
+ // (any-typed JSON.parse results, most commonly). Those errors are OURS,
6431
+ // not the project's, so they must not fail preflight: when the lowering
6432
+ // world has errors, the PROJECT world (same program without the override
6433
+ // declarations) is built and consulted. Clean there → preflight passes
6434
+ // and the override-affected sites meet the lowerer's honest fences
6435
+ // instead (the SC1100 checked-cast family). Dirty there → the project-
6436
+ // world errors are the ones reported: they are reproducible with the
6437
+ // project's own tsc, which is what "fix type errors first" asks for.
6438
+ // With JSX sources, the program over the original text answers the tsc
6439
+ // gate; its positions move into the rewritten text the program holds.
6440
+ // Errors only the rewritten text has come from the calls the JSX lowers
6441
+ // to (a factory whose signature does not accept them).
6442
+ const tscWorld = load.tscWorld;
6443
+ const tscErrors = tscWorld === undefined ? errorsOf(program) : keptErrors(tscWorld.program, tscWorld.diagnostics);
6444
+ if (tscErrors.length > 0) {
6445
+ const world = tscWorld === undefined || tscWorld.declWorldFallback === true
6446
+ ? load.projectWorld()
6447
+ : (tscWorld.projectWorld ?? tscWorld.program);
6448
+ for (const d of errorsOf(world)) {
6449
+ const diag = toPassthrough(d);
6450
+ const lowered = tscWorld === undefined ? undefined : load.jsxSources?.get(diag.loc.file);
6451
+ if (lowered !== undefined) {
6452
+ diag.loc = {
6453
+ ...diag.loc,
6454
+ start: lowered.rewrittenPosition(diag.loc.start, false),
6455
+ end: lowered.rewrittenPosition(diag.loc.end, true),
6456
+ };
6457
+ }
6458
+ diags.push(diag);
6459
+ }
6460
+ }
6461
+ else if (load.jsxSources !== undefined) {
6462
+ for (const file of load.jsxSources.keys()) {
6463
+ const sf = program.getSourceFile(file);
6464
+ if (sf === undefined)
6465
+ continue;
6466
+ const own = [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)];
6467
+ for (const d of keptErrors(program, own)) {
6468
+ const diag = toPassthrough(d);
6469
+ diag.message = `${diag.message} (in the call this JSX lowers to)`;
6470
+ diags.push(diag);
6471
+ }
6472
+ }
6473
+ }
6474
+ return { diags, admittedOpinions: [...admittedOpinions.values()] };
6202
6475
  }
6203
6476
  /* ── the CJS named-import link check ─────────────────────────────────────
6204
6477
  * Node builds a CommonJS module's ESM facade from its LEXER (cjs-lexer.ts
@@ -6794,7 +7067,7 @@ const nodeBuiltinNames = new Set(builtinModules);
6794
7067
  export { ambientDtsPath, fallbackDtsPath, isFallbackDtsPath, isNodeTypesPath, overridesDtsPath, } from "./dts-paths.js";
6795
7068
  export { builtinDefaultImportModule, canonicalBuiltinModule, npmBuiltinAliasOf, SUPPORTED_BUILTIN_MODULES, } from "./builtin-modules.js";
6796
7069
  export { npmPackageNameOf, workspacePackageOfPath } from "./workspace-registry.js";
6797
- export { requireSpecOf7 as requireSpecOf, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, splitRequireCallOf7 as splitRequireCallOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
7070
+ export { requireSpecOf7 as requireSpecOf, requireCallBindingKind7 as requireCallBindingKind, isRequireStatement7 as isRequireStatement, requiresOf7 as requiresOf, splitRequireCallOf7 as splitRequireCallOf, isNodeEsmFile7 as isNodeEsmFile, resolveImport7 as resolveImport, resolveNpmImport7 as resolveNpmImport, locOf7 as locOf, requireEarlyReference7 as requireEarlyReference, inDeferredPosition7 as inDeferredPosition, };
6798
7071
  /** True for JavaScript source files (.js/.mjs/.cjs) — the files whose
6799
7072
  * types come entirely from inference (checkJs + JSDoc) and whose classes
6800
7073
  * declare fields by constructor assignment. */