ttsc 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/README.md +2 -0
  2. package/cmd/ttsc/api_compile.go +3 -2
  3. package/cmd/ttsc/api_transform.go +1 -1
  4. package/cmd/ttsc/build.go +5 -4
  5. package/cmd/ttsc-cache/account.go +16 -0
  6. package/cmd/ttsc-cache/account_test.go +91 -0
  7. package/cmd/ttsc-cache/main.go +1 -1
  8. package/cmd/ttsc-cache/protocol_test.go +2 -2
  9. package/cmd/ttsc-cache/publisher_seal_test.go +1 -1
  10. package/cmd/ttsc-cache/stock_go_failure_test.go +1 -1
  11. package/cmd/ttsc-cache/stock_go_test.go +2 -2
  12. package/cmd/ttsc-cache/store.go +5 -0
  13. package/cmd/ttsc-cache/tuple.go +6 -2
  14. package/cmd/ttsc-cache/tuple_test.go +1 -1
  15. package/cmd/ttscgraph/main.go +6 -1
  16. package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +6 -1
  17. package/cmd/ttscgraph/serve.go +22 -20
  18. package/cmd/ttscgraph/serve_alternative_members_and_reads_refresh_test.go +95 -0
  19. package/cmd/ttscgraph/serve_shards.go +26 -15
  20. package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +2 -2
  21. package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +3 -3
  22. package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +1 -1
  23. package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +3 -3
  24. package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +2 -2
  25. package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +3 -3
  26. package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +5 -5
  27. package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +8 -8
  28. package/cmd/ttscgraph/serve_source_encoding_test.go +2 -2
  29. package/driver/build_information_uses_selected_output_identity_test.go +5 -4
  30. package/driver/check_observations.go +1 -1
  31. package/driver/config_discovery.go +5 -1
  32. package/driver/declaration_shape.go +15 -21
  33. package/driver/diagnostics_preamble.go +2 -2
  34. package/driver/emit_containment.go +11 -14
  35. package/driver/emit_plugin.go +51 -43
  36. package/driver/emit_plugin_output.go +6 -5
  37. package/driver/emit_provenance.go +12 -15
  38. package/driver/graph.go +8 -8
  39. package/driver/host.go +15 -5
  40. package/driver/input_observation.go +22 -21
  41. package/driver/input_observation_test.go +11 -10
  42. package/driver/overlay.go +11 -11
  43. package/driver/program.go +102 -51
  44. package/driver/resolution_candidates.go +50 -32
  45. package/driver/resolution_candidates_test.go +18 -5
  46. package/driver/rewrite.go +11 -13
  47. package/driver/session.go +13 -7
  48. package/driver/target_ts70.go +85 -0
  49. package/driver/target_ts71.go +97 -0
  50. package/driver/transform_dependencies.go +1 -1
  51. package/driver/transform_source_map.go +21 -20
  52. package/go.mod +3 -3
  53. package/go.sum +4 -4
  54. package/internal/graph/alternative_member_declarations_resolve_uses_test.go +145 -0
  55. package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +2 -2
  56. package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +2 -2
  57. package/internal/graph/build.go +75 -33
  58. package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +4 -4
  59. package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +1 -1
  60. package/internal/graph/declaration_members.go +143 -0
  61. package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +3 -3
  62. package/internal/graph/doc_tags.go +2 -2
  63. package/internal/graph/dump_paths.go +6 -5
  64. package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +1 -1
  65. package/internal/graph/edges.go +151 -68
  66. package/internal/graph/edges_cover_class_level_references_test.go +5 -5
  67. package/internal/graph/enum_initializer_calls_are_edges_test.go +2 -2
  68. package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +6 -6
  69. package/internal/graph/exports.go +6 -6
  70. package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +2 -2
  71. package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +1 -1
  72. package/internal/graph/function_locals_do_not_collide_test.go +3 -3
  73. package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +5 -5
  74. package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +2 -2
  75. package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +3 -3
  76. package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +3 -3
  77. package/internal/graph/literals.go +3 -3
  78. package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +2 -2
  79. package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +4 -4
  80. package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +2 -2
  81. package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +1 -1
  82. package/internal/graph/literals_resolve_through_alias_indirection_test.go +3 -3
  83. package/internal/graph/member_relation_edges_follow_checker_validity_test.go +7 -7
  84. package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +19 -19
  85. package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +11 -11
  86. package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +2 -2
  87. package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +7 -7
  88. package/internal/graph/namespace_private_declarations_keep_lexical_identity_test.go +85 -0
  89. package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +2 -2
  90. package/internal/graph/object_literal_declarations_resolve_calls_test.go +9 -9
  91. package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +1 -1
  92. package/internal/graph/overload_implementation_replaces_signature_test.go +2 -2
  93. package/internal/graph/property_member_edges_remain_owner_visible_test.go +6 -6
  94. package/internal/graph/resolve.go +37 -12
  95. package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +6 -6
  96. package/internal/graph/source.go +1 -1
  97. package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +7 -7
  98. package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +2 -2
  99. package/internal/graph/value_access_edges_cover_properties_test.go +5 -5
  100. package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +3 -3
  101. package/internal/graph/value_call_edges_cover_jsx_components_test.go +2 -2
  102. package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +3 -3
  103. package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +2 -2
  104. package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +4 -4
  105. package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +3 -3
  106. package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +2 -2
  107. package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +4 -4
  108. package/internal/graph/value_reads_cover_expression_positions_test.go +88 -0
  109. package/lib/compiler/internal/buildNativeCompiler.d.ts +5 -2
  110. package/lib/compiler/internal/buildNativeCompiler.js +12 -4
  111. package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
  112. package/lib/flags/COMPILER_ENUM_WHITESPACE.js +1 -1
  113. package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -1
  114. package/lib/flags/COMPILER_OPTIONS.js +1079 -149
  115. package/lib/flags/COMPILER_OPTIONS.js.map +1 -1
  116. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +1 -1
  117. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -1
  118. package/lib/flags/COMPILER_OPTION_KINDS.js +1 -1
  119. package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -1
  120. package/lib/flags/CompilerOptionSpec.d.ts +9 -2
  121. package/lib/internal/pluginSource.d.ts +1 -0
  122. package/lib/internal/pluginSource.js +1 -0
  123. package/lib/internal/pluginSource.js.map +1 -1
  124. package/lib/launcher/internal/TypeScriptSyncApi.d.ts +140 -0
  125. package/lib/launcher/internal/TypeScriptSyncApi.js +99 -0
  126. package/lib/launcher/internal/TypeScriptSyncApi.js.map +1 -0
  127. package/lib/launcher/internal/buildSingleRootInMemory.d.ts +80 -0
  128. package/lib/launcher/internal/buildSingleRootInMemory.js +253 -0
  129. package/lib/launcher/internal/buildSingleRootInMemory.js.map +1 -0
  130. package/lib/launcher/internal/buildSingleRootProject.d.ts +22 -18
  131. package/lib/launcher/internal/buildSingleRootProject.js +27 -18
  132. package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
  133. package/lib/launcher/internal/compilerArgsAsConfigOptions.d.ts +39 -0
  134. package/lib/launcher/internal/compilerArgsAsConfigOptions.js +115 -0
  135. package/lib/launcher/internal/compilerArgsAsConfigOptions.js.map +1 -0
  136. package/lib/plugin/CapabilityPluginResolver.js +3 -0
  137. package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
  138. package/lib/plugin/internal/load/loadProjectPlugins.js +6 -2
  139. package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
  140. package/lib/plugin/internal/source/CompilerTarget.d.ts +127 -0
  141. package/lib/plugin/internal/source/CompilerTarget.js +231 -0
  142. package/lib/plugin/internal/source/CompilerTarget.js.map +1 -0
  143. package/lib/plugin/internal/source/NativeSourcePackages.js +6 -5
  144. package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
  145. package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +18 -1
  146. package/lib/plugin/internal/source/SourcePluginAdmission.js +24 -2
  147. package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -1
  148. package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +6 -3
  149. package/lib/plugin/internal/source/SourcePluginWorkspace.js +31 -13
  150. package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
  151. package/lib/plugin/internal/source/buildSourcePlugin.js +3 -1
  152. package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
  153. package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +1 -1
  154. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +9 -1
  155. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
  156. package/package.json +14 -9
  157. package/shim/ast/enums_gen.go +1 -0
  158. package/shim/ast/go.mod +2 -2
  159. package/shim/ast/go.sum +4 -4
  160. package/shim/ast/neutral.go +141 -0
  161. package/shim/astnav/go.mod +2 -2
  162. package/shim/astnav/go.sum +4 -4
  163. package/shim/bundled/go.mod +2 -2
  164. package/shim/bundled/go.sum +4 -4
  165. package/shim/checker/go.mod +2 -2
  166. package/shim/checker/go.sum +4 -4
  167. package/shim/compiler/go.mod +2 -2
  168. package/shim/compiler/go.sum +4 -4
  169. package/shim/compiler/neutral.go +213 -0
  170. package/shim/core/go.mod +2 -2
  171. package/shim/core/go.sum +4 -4
  172. package/shim/diagnosticwriter/go.mod +2 -2
  173. package/shim/diagnosticwriter/go.sum +4 -4
  174. package/shim/lsp/go.mod +2 -2
  175. package/shim/lsp/go.sum +4 -4
  176. package/shim/parser/go.mod +2 -2
  177. package/shim/parser/go.sum +4 -4
  178. package/shim/printer/go.mod +2 -2
  179. package/shim/printer/go.sum +4 -4
  180. package/shim/scanner/go.mod +2 -2
  181. package/shim/scanner/go.sum +4 -4
  182. package/shim/stringutil/go.mod +1 -1
  183. package/shim/stringutil/go.sum +2 -2
  184. package/shim/stringutil/shim.go +15 -0
  185. package/shim/transformers/go.mod +2 -2
  186. package/shim/transformers/go.sum +4 -4
  187. package/shim/tsoptions/go.mod +2 -2
  188. package/shim/tsoptions/go.sum +4 -4
  189. package/shim/tsoptions/neutral.go +56 -0
  190. package/shim/tspath/go.mod +1 -1
  191. package/shim/tspath/go.sum +2 -2
  192. package/shim/tspath/neutral.go +150 -0
  193. package/shim/tspath/typed_paths.go +266 -0
  194. package/shim/vfs/cachedvfs/go.mod +2 -2
  195. package/shim/vfs/cachedvfs/go.sum +4 -4
  196. package/shim/vfs/go.mod +2 -2
  197. package/shim/vfs/go.sum +4 -4
  198. package/shim/vfs/neutral.go +20 -0
  199. package/shim/vfs/osvfs/go.mod +2 -2
  200. package/shim/vfs/osvfs/go.sum +4 -4
  201. package/src/compiler/internal/buildNativeCompiler.ts +13 -4
  202. package/src/flags/COMPILER_ENUM_WHITESPACE.ts +1 -1
  203. package/src/flags/COMPILER_OPTIONS.ts +1080 -150
  204. package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +1 -1
  205. package/src/flags/COMPILER_OPTION_KINDS.ts +1 -1
  206. package/src/flags/CompilerOptionSpec.ts +11 -2
  207. package/src/internal/pluginSource.ts +1 -0
  208. package/src/launcher/internal/TypeScriptSyncApi.ts +186 -0
  209. package/src/launcher/internal/buildSingleRootInMemory.ts +319 -0
  210. package/src/launcher/internal/buildSingleRootProject.ts +26 -18
  211. package/src/launcher/internal/compilerArgsAsConfigOptions.ts +112 -0
  212. package/src/plugin/CapabilityPluginResolver.ts +4 -1
  213. package/src/plugin/internal/load/loadProjectPlugins.ts +12 -2
  214. package/src/plugin/internal/source/CompilerTarget.ts +249 -0
  215. package/src/plugin/internal/source/NativeSourcePackages.ts +10 -4
  216. package/src/plugin/internal/source/SourcePluginAdmission.ts +28 -2
  217. package/src/plugin/internal/source/SourcePluginWorkspace.ts +45 -19
  218. package/src/plugin/internal/source/buildSourcePlugin.ts +3 -1
  219. package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +9 -1
  220. package/targets/7.1/bridge/ast/enums_gen.go +174 -0
  221. package/targets/7.1/bridge/ast/extra-shim.json +4 -0
  222. package/targets/7.1/bridge/ast/go.mod +14 -0
  223. package/targets/7.1/bridge/ast/go.sum +20 -0
  224. package/targets/7.1/bridge/ast/lint.go +1412 -0
  225. package/targets/7.1/bridge/ast/neutral.go +141 -0
  226. package/targets/7.1/bridge/ast/parent.go +60 -0
  227. package/targets/7.1/bridge/ast/safe_text.go +108 -0
  228. package/targets/7.1/bridge/ast/shim.go +1656 -0
  229. package/targets/7.1/bridge/ast/surface.go +686 -0
  230. package/targets/7.1/bridge/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
  231. package/targets/7.1/bridge/ast/test/node_text_joins_multi_hop_qualified_name_test.go +47 -0
  232. package/targets/7.1/bridge/ast/test/node_text_joins_one_hop_qualified_name_test.go +35 -0
  233. package/targets/7.1/bridge/ast/test/node_text_returns_empty_for_nil_test.go +31 -0
  234. package/targets/7.1/bridge/ast/test/node_text_returns_identifier_text_test.go +34 -0
  235. package/targets/7.1/bridge/ast/test/node_text_skips_empty_qualified_left_test.go +60 -0
  236. package/targets/7.1/bridge/astnav/go.mod +14 -0
  237. package/targets/7.1/bridge/astnav/go.sum +22 -0
  238. package/targets/7.1/bridge/astnav/shim.go +24 -0
  239. package/targets/7.1/bridge/bundled/extra-shim.json +1 -0
  240. package/targets/7.1/bridge/bundled/go.mod +10 -0
  241. package/targets/7.1/bridge/bundled/go.sum +10 -0
  242. package/targets/7.1/bridge/bundled/shim.go +24 -0
  243. package/targets/7.1/bridge/checker/enums_gen.go +150 -0
  244. package/targets/7.1/bridge/checker/extra-shim.json +37 -0
  245. package/targets/7.1/bridge/checker/go.mod +15 -0
  246. package/targets/7.1/bridge/checker/go.sum +24 -0
  247. package/targets/7.1/bridge/checker/node_builder_fields_gen.go +19 -0
  248. package/targets/7.1/bridge/checker/shim.go +1390 -0
  249. package/targets/7.1/bridge/compiler/contentmapper_process.go +70 -0
  250. package/targets/7.1/bridge/compiler/emit_sourcemap.go +296 -0
  251. package/targets/7.1/bridge/compiler/emitassemble.go +81 -0
  252. package/targets/7.1/bridge/compiler/emithook.go +44 -0
  253. package/targets/7.1/bridge/compiler/extra-shim.json +4 -0
  254. package/targets/7.1/bridge/compiler/go.mod +15 -0
  255. package/targets/7.1/bridge/compiler/go.sum +24 -0
  256. package/targets/7.1/bridge/compiler/incremental.go +185 -0
  257. package/targets/7.1/bridge/compiler/neutral.go +256 -0
  258. package/targets/7.1/bridge/compiler/resolution.go +571 -0
  259. package/targets/7.1/bridge/compiler/shim.go +70 -0
  260. package/targets/7.1/bridge/core/enums_gen.go +15 -0
  261. package/targets/7.1/bridge/core/extra-shim.json +4 -0
  262. package/targets/7.1/bridge/core/go.mod +7 -0
  263. package/targets/7.1/bridge/core/go.sum +8 -0
  264. package/targets/7.1/bridge/core/modulekind.go +19 -0
  265. package/targets/7.1/bridge/core/shim.go +272 -0
  266. package/targets/7.1/bridge/diagnosticwriter/go.mod +14 -0
  267. package/targets/7.1/bridge/diagnosticwriter/go.sum +20 -0
  268. package/targets/7.1/bridge/diagnosticwriter/lint.go +411 -0
  269. package/targets/7.1/bridge/diagnosticwriter/shim.go +56 -0
  270. package/targets/7.1/bridge/lsp/extra-shim.json +4 -0
  271. package/targets/7.1/bridge/lsp/go.mod +16 -0
  272. package/targets/7.1/bridge/lsp/go.sum +26 -0
  273. package/targets/7.1/bridge/lsp/shim.go +112 -0
  274. package/targets/7.1/bridge/parser/extra-shim.json +4 -0
  275. package/targets/7.1/bridge/parser/go.mod +14 -0
  276. package/targets/7.1/bridge/parser/go.sum +24 -0
  277. package/targets/7.1/bridge/parser/shim.go +61 -0
  278. package/targets/7.1/bridge/printer/emithost.go +69 -0
  279. package/targets/7.1/bridge/printer/go.mod +15 -0
  280. package/targets/7.1/bridge/printer/go.sum +24 -0
  281. package/targets/7.1/bridge/printer/shim.go +168 -0
  282. package/targets/7.1/bridge/printer/sourcemap.go +49 -0
  283. package/targets/7.1/bridge/scanner/extra-shim.json +4 -0
  284. package/targets/7.1/bridge/scanner/go.mod +14 -0
  285. package/targets/7.1/bridge/scanner/go.sum +20 -0
  286. package/targets/7.1/bridge/scanner/regexp.go +42 -0
  287. package/targets/7.1/bridge/scanner/shim.go +137 -0
  288. package/targets/7.1/bridge/stringutil/extra-shim.json +1 -0
  289. package/targets/7.1/bridge/stringutil/go.mod +5 -0
  290. package/targets/7.1/bridge/stringutil/go.sum +2 -0
  291. package/targets/7.1/bridge/stringutil/shim.go +131 -0
  292. package/targets/7.1/bridge/transformers/go.mod +15 -0
  293. package/targets/7.1/bridge/transformers/go.sum +24 -0
  294. package/targets/7.1/bridge/transformers/shim.go +24 -0
  295. package/targets/7.1/bridge/tsoptions/command_line_raw.go +44 -0
  296. package/targets/7.1/bridge/tsoptions/extra-shim.json +4 -0
  297. package/targets/7.1/bridge/tsoptions/go.mod +15 -0
  298. package/targets/7.1/bridge/tsoptions/go.sum +24 -0
  299. package/targets/7.1/bridge/tsoptions/neutral.go +47 -0
  300. package/targets/7.1/bridge/tsoptions/shim.go +193 -0
  301. package/targets/7.1/bridge/tspath/extra-shim.json +4 -0
  302. package/targets/7.1/bridge/tspath/go.mod +5 -0
  303. package/targets/7.1/bridge/tspath/go.sum +6 -0
  304. package/targets/7.1/bridge/tspath/neutral.go +142 -0
  305. package/targets/7.1/bridge/tspath/shim.go +382 -0
  306. package/targets/7.1/bridge/vfs/cachedvfs/extra-shim.json +4 -0
  307. package/targets/7.1/bridge/vfs/cachedvfs/go.mod +5 -0
  308. package/targets/7.1/bridge/vfs/cachedvfs/go.sum +10 -0
  309. package/targets/7.1/bridge/vfs/cachedvfs/shim.go +12 -0
  310. package/targets/7.1/bridge/vfs/decode.go +26 -0
  311. package/targets/7.1/bridge/vfs/decode_test.go +42 -0
  312. package/targets/7.1/bridge/vfs/extra-shim.json +4 -0
  313. package/targets/7.1/bridge/vfs/go.mod +10 -0
  314. package/targets/7.1/bridge/vfs/go.sum +10 -0
  315. package/targets/7.1/bridge/vfs/neutral.go +23 -0
  316. package/targets/7.1/bridge/vfs/osvfs/extra-shim.json +4 -0
  317. package/targets/7.1/bridge/vfs/osvfs/go.mod +10 -0
  318. package/targets/7.1/bridge/vfs/osvfs/go.sum +10 -0
  319. package/targets/7.1/bridge/vfs/osvfs/shim.go +14 -0
  320. package/targets/7.1/bridge/vfs/shim.go +27 -0
  321. package/targets/7.1/facade/ast/facade_gen.go +2691 -0
  322. package/targets/7.1/facade/ast/go.mod +20 -0
  323. package/targets/7.1/facade/ast/go.sum +20 -0
  324. package/targets/7.1/facade/astnav/facade_gen.go +15 -0
  325. package/targets/7.1/facade/astnav/go.mod +22 -0
  326. package/targets/7.1/facade/astnav/go.sum +22 -0
  327. package/targets/7.1/facade/bundled/facade_gen.go +32 -0
  328. package/targets/7.1/facade/bundled/go.mod +21 -0
  329. package/targets/7.1/facade/bundled/go.sum +10 -0
  330. package/targets/7.1/facade/checker/facade_gen.go +563 -0
  331. package/targets/7.1/facade/checker/go.mod +26 -0
  332. package/targets/7.1/facade/checker/go.sum +24 -0
  333. package/targets/7.1/facade/compiler/facade_gen.go +198 -0
  334. package/targets/7.1/facade/compiler/go.mod +41 -0
  335. package/targets/7.1/facade/compiler/go.sum +24 -0
  336. package/targets/7.1/facade/core/facade_gen.go +130 -0
  337. package/targets/7.1/facade/core/go.mod +12 -0
  338. package/targets/7.1/facade/core/go.sum +8 -0
  339. package/targets/7.1/facade/diagnosticwriter/facade_gen.go +36 -0
  340. package/targets/7.1/facade/diagnosticwriter/go.mod +22 -0
  341. package/targets/7.1/facade/diagnosticwriter/go.sum +20 -0
  342. package/targets/7.1/facade/lsp/facade_gen.go +31 -0
  343. package/targets/7.1/facade/lsp/go.mod +19 -0
  344. package/targets/7.1/facade/lsp/go.sum +26 -0
  345. package/targets/7.1/facade/parser/facade_gen.go +102 -0
  346. package/targets/7.1/facade/parser/go.mod +25 -0
  347. package/targets/7.1/facade/parser/go.sum +24 -0
  348. package/targets/7.1/facade/printer/facade_gen.go +74 -0
  349. package/targets/7.1/facade/printer/go.mod +26 -0
  350. package/targets/7.1/facade/printer/go.sum +24 -0
  351. package/targets/7.1/facade/scanner/facade_gen.go +191 -0
  352. package/targets/7.1/facade/scanner/go.mod +25 -0
  353. package/targets/7.1/facade/scanner/go.sum +20 -0
  354. package/targets/7.1/facade/stringutil/facade_gen.go +176 -0
  355. package/targets/7.1/facade/stringutil/go.mod +9 -0
  356. package/targets/7.1/facade/stringutil/go.sum +2 -0
  357. package/targets/7.1/facade/transformers/facade_gen.go +12 -0
  358. package/targets/7.1/facade/transformers/go.mod +18 -0
  359. package/targets/7.1/facade/transformers/go.sum +24 -0
  360. package/targets/7.1/facade/tsoptions/facade_gen.go +274 -0
  361. package/targets/7.1/facade/tsoptions/go.mod +32 -0
  362. package/targets/7.1/facade/tsoptions/go.sum +24 -0
  363. package/targets/7.1/facade/tspath/facade_gen.go +550 -0
  364. package/targets/7.1/facade/tspath/go.mod +9 -0
  365. package/targets/7.1/facade/tspath/go.sum +6 -0
  366. package/targets/7.1/facade/vfs/cachedvfs/facade_gen.go +17 -0
  367. package/targets/7.1/facade/vfs/cachedvfs/go.mod +18 -0
  368. package/targets/7.1/facade/vfs/cachedvfs/go.sum +10 -0
  369. package/targets/7.1/facade/vfs/facade_gen.go +47 -0
  370. package/targets/7.1/facade/vfs/go.mod +18 -0
  371. package/targets/7.1/facade/vfs/go.sum +10 -0
  372. package/targets/7.1/facade/vfs/osvfs/facade_gen.go +20 -0
  373. package/targets/7.1/facade/vfs/osvfs/go.mod +21 -0
  374. package/targets/7.1/facade/vfs/osvfs/go.sum +10 -0
  375. package/tools/gen_facade/committed_facades_match_their_bridges_test.go +57 -0
  376. package/tools/gen_facade/facade_manifest_points_into_the_bridge_root_test.go +75 -0
  377. package/tools/gen_facade/facade_spells_internal_types_through_bridge_aliases_test.go +75 -0
  378. package/tools/gen_facade/facade_types_are_their_bridge_types_test.go +99 -0
  379. package/tools/gen_facade/go.mod +10 -0
  380. package/tools/gen_facade/go.sum +8 -0
  381. package/tools/gen_facade/main.go +734 -0
  382. package/tools/gen_shims/go.mod +4 -4
  383. package/tools/gen_shims/go.sum +6 -6
  384. package/tools/gen_shims/main.go +124 -66
  385. package/tools/gen_shims/mirror_structs_terminate_on_unexported_cycles_test.go +101 -0
  386. package/tools/shim_audit/baseline-7.1.json +720 -0
  387. package/tools/shim_audit/baseline.json +5 -4
  388. package/tools/shim_audit/go.mod +4 -4
  389. package/tools/shim_audit/go.sum +6 -6
  390. package/tools/shim_audit/linkname_signatures.go +178 -0
  391. package/tools/shim_audit/linkname_signatures_match_their_targets_test.go +64 -0
  392. package/tools/shim_audit/linkname_targets_follow_the_audited_compiler_test.go +38 -0
  393. package/tools/shim_audit/main.go +29 -4
  394. package/tools/shim_audit/neutral_api.go +160 -0
  395. package/tools/shim_audit/neutral_api_must_match_across_targets_test.go +74 -0
  396. package/utility/host.go +5 -4
  397. package/utility/preamble_output.go +15 -15
  398. package/utility/serve.go +1 -1
@@ -0,0 +1,112 @@
1
+ import path from "node:path";
2
+
3
+ import { normalizeCompilerEnumValue } from "../../flags/normalizeCompilerEnumValue";
4
+ import { readCompilerOptionOccurrence } from "../../flags/readCompilerOptionOccurrence";
5
+
6
+ /**
7
+ * Translate compiler command-line arguments into the `compilerOptions` of a
8
+ * tsconfig that extends the project, so that a build which opens that tsconfig
9
+ * alone sees the options the arguments would have given it.
10
+ *
11
+ * TypeScript applies command-line options over the options of the config it
12
+ * builds, and an extending config's own `compilerOptions` override the config
13
+ * it extends in the same way. So the assignments of `args`, written into the
14
+ * extending config, win over the project exactly as they would on the command
15
+ * line. Each value is converted the way the compiler parses it from argv: the
16
+ * last occurrence of an option wins; `null` resets an inherited value; enum
17
+ * values are trimmed and lowercased; a list value is split at commas and loses
18
+ * its empty members; and a value that names a path is resolved against `cwd`,
19
+ * because the compiler resolves a command-line path against its working
20
+ * directory while a config path resolves against the config's directory.
21
+ *
22
+ * Arguments that a config cannot carry make the translation unavailable, so the
23
+ * caller keeps a build that passes them on the command line: a response file, a
24
+ * positional file name, an unknown option, an option the compiler accepts only
25
+ * on the command line, a project selection, the trace and profile options whose
26
+ * artifacts the compiler writes itself, and a value containing `${configDir}`,
27
+ * which a config would substitute and the command line does not. The
28
+ * translation assumes valid arguments; the caller confirms them with the same
29
+ * compiler's own command-line parser before using the result.
30
+ *
31
+ * @param args Compiler arguments without the leading `-p <tsconfig>`.
32
+ * @param cwd The directory the compiler would run in.
33
+ * @returns The assignments by canonical option name, or `undefined` when the
34
+ * arguments cannot be carried by a config.
35
+ * @evidence contracts/common.md#principled-implementation Each occurrence is classified by the pinned native grammar (readCompilerOptionOccurrence) and its value converted by the native command-line rules: null resets, last occurrence wins, enum trim and lowercase, list TrimSpace and comma split with empty members dropped, and paths resolved against the working directory. Command-line options override the configured ones as an extending config's options override its base, so writing them into the extending config preserves precedence. Premise: the arguments are valid; the caller verifies that with the consumer compiler's parseCommandLine. Options newer than the pinned table are unknown here and make the translation unavailable.
36
+ * @evidence contracts/common.md#clear-and-simple-design One pure function owns the argv-to-config translation; the build that consumes it owns compiler selection, validation and emission.
37
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Unsupported argument classes return undefined so the caller keeps the command-line build instead of approximating them; no option is special-cased by consumer or fixture.
38
+ * @evidence contracts/common.md#meaningful-documentation The prose states the precedence premise, every conversion rule, each class that makes the translation unavailable and the validity premise.
39
+ * @evidence contracts/portability.md#os-neutral-implementation Path values are resolved with node:path against the supplied working directory, so drive letters and separators follow the host; no other value is touched as a path.
40
+ * @evidence contracts/performance.md#efficient-algorithms One pass over the arguments with a constant-time table lookup per option and a split per list value.
41
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The translation depends only on its arguments and is computed once per build.
42
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned record is the only allocation and transfers to the caller.
43
+ */
44
+ export function compilerArgsAsConfigOptions(
45
+ args: readonly string[],
46
+ cwd: string,
47
+ ): Record<string, unknown> | undefined {
48
+ const options: Record<string, unknown> = {};
49
+ for (let index = 0; index < args.length; ) {
50
+ if (args[index]!.startsWith("@")) return undefined;
51
+ const occurrence = readCompilerOptionOccurrence(args, index);
52
+ const option = occurrence.option;
53
+ if (
54
+ option === undefined ||
55
+ option.commandLineOnly ||
56
+ COMMAND_LINE_OUTPUTS.has(option.name)
57
+ )
58
+ return undefined;
59
+ const next = occurrence.width === 2 ? args[index + 1]! : undefined;
60
+ let value: unknown;
61
+ if (next === "null") value = null;
62
+ else if (option.configOnly) {
63
+ // The command line accepts only `null`, or `false` for a boolean.
64
+ if (option.kind !== "boolean" || next !== "false") return undefined;
65
+ value = false;
66
+ } else if (option.kind === "boolean") value = occurrence.booleanValue;
67
+ else if (next === undefined)
68
+ // A list whose value is empty; any other kind is an invalid argument.
69
+ value = [];
70
+ else if (next.includes("${configDir}")) return undefined;
71
+ else if (option.kind === "number") value = Number(next);
72
+ else if (option.kind === "enum")
73
+ value = normalizeCompilerEnumValue(next, "cli");
74
+ else if (option.kind === "list")
75
+ value = splitList(next, option.element === "enum", option.filePath, cwd);
76
+ else value = option.filePath ? path.resolve(cwd, next) : next;
77
+ options[option.name] = value;
78
+ index += occurrence.width;
79
+ }
80
+ return options;
81
+ }
82
+
83
+ /**
84
+ * Options whose output the compiler writes itself, outside the emit: a config
85
+ * route that only collects emitted files cannot produce them.
86
+ */
87
+ const COMMAND_LINE_OUTPUTS: ReadonlySet<string> = new Set([
88
+ "project",
89
+ "generateTrace",
90
+ "generateCpuProfile",
91
+ "pprofDir",
92
+ ]);
93
+
94
+ /** Members of a command-line list value, as the native parser reads them. */
95
+ function splitList(
96
+ value: string,
97
+ enumMembers: boolean,
98
+ filePath: boolean,
99
+ cwd: string,
100
+ ): string[] {
101
+ // Go strings.TrimSpace follows Unicode White_Space for the whole value;
102
+ // enum members are then trimmed with the compiler's IsWhiteSpaceLike set.
103
+ const trimmed = value.replace(/^\p{White_Space}+|\p{White_Space}+$/gu, "");
104
+ if (trimmed === "" || trimmed.startsWith("-")) return [];
105
+ const members: string[] = [];
106
+ for (const part of trimmed.split(",")) {
107
+ const member = enumMembers ? normalizeCompilerEnumValue(part, "cli") : part;
108
+ if (member === null || member === "") continue;
109
+ members.push(filePath ? path.resolve(cwd, member) : member);
110
+ }
111
+ return members;
112
+ }
@@ -69,7 +69,10 @@ export class CapabilityPluginResolver {
69
69
  return {
70
70
  status: value.status,
71
71
  plugins: value.plugins,
72
- isCurrent: async ({ signal } = {}) =>
72
+ // TypeScript 7.1 nightlies drop the contextual type of a defaulted
73
+ // binding pattern (microsoft/TypeScript#64431, fix in #64671), so the
74
+ // option type is spelled out for both compiler lines.
75
+ isCurrent: async ({ signal }: { signal?: AbortSignal } = {}) =>
73
76
  released || this.closed
74
77
  ? false
75
78
  : ((await this.request(
@@ -24,6 +24,7 @@ import type { ITtscParsedProjectConfig } from "../../../structures/internal/ITts
24
24
  import type { TtscPluginSourceInputsHandler } from "../../../structures/internal/TtscSingleFileEmitOptions";
25
25
  import { pluginDescriptorFailureReason } from "../pluginDescriptorFailureReason";
26
26
  import { pluginDescriptorProcessFailure } from "../pluginDescriptorProcessFailure";
27
+ import { CompilerTarget } from "../source/CompilerTarget";
27
28
  import { NativeSourcePackages } from "../source/NativeSourcePackages";
28
29
  import type { PluginBuildEnvironmentWitness } from "../source/PluginBuildEnvironmentWitness";
29
30
  import { PluginContentIdentities } from "../source/PluginContentIdentities";
@@ -242,7 +243,7 @@ export namespace loadProjectPlugins {
242
243
  // host-owned Node/ttsx locators into process.env. Under a Bun parent the
243
244
  // direct descriptor evaluator must remain Bun unless the caller explicitly
244
245
  // selected another runtime.
245
- const effectiveEnv = SidecarEnvironment.merge(options.env ?? process.env);
246
+ const callerEnv = SidecarEnvironment.merge(options.env ?? process.env);
246
247
  const projectSnapshot = readProjectHostInputSnapshot({
247
248
  cwd: options.cwd,
248
249
  file: options.file,
@@ -285,6 +286,13 @@ export namespace loadProjectPlugins {
285
286
  };
286
287
  }
287
288
 
289
+ // Every Go command of this load compiles the compiler target of the
290
+ // project's TypeScript line; the target travels in the environment.
291
+ const effectiveEnv = CompilerTarget.buildEnv(
292
+ callerEnv,
293
+ CompilerTarget.resolve(project.root, callerEnv),
294
+ project.root,
295
+ );
288
296
  const cwd = path.resolve(options.cwd ?? process.cwd());
289
297
  const context = {
290
298
  binary: options.binary,
@@ -462,7 +470,9 @@ export namespace loadProjectPlugins {
462
470
  candidate.packageDir,
463
471
  ...(candidate.contributors ?? []).map((input) => input.source),
464
472
  ]),
465
- ...SourcePluginWorkspace.findTtscOverlayDirs(),
473
+ ...SourcePluginWorkspace.findTtscOverlayDirs(
474
+ CompilerTarget.ofEnv(effectiveEnv),
475
+ ),
466
476
  ]);
467
477
  // One fixed-effective-environment load owns manifest syntax sharing from the
468
478
  // first watch query through metadata and builds. Do not allocate this after
@@ -0,0 +1,249 @@
1
+ import { outputText } from "../../../compiler/internal/outputText";
2
+ import { resolveTsgo } from "../../../compiler/internal/resolveTsgo";
3
+ import { SidecarEnvironment } from "../../../compiler/internal/sharedHost/SidecarEnvironment";
4
+ import { spawnNative } from "../../../compiler/internal/spawnNative";
5
+ import { GoSourceInputs } from "./GoSourceInputs";
6
+ import { GoToolResolution } from "./GoToolResolution";
7
+ import { resolveGoCompiler } from "./resolveGoCompiler";
8
+ import { spawnGoTool } from "./spawnGoTool";
9
+
10
+ /**
11
+ * The compiler target a source build compiles against, chosen from the
12
+ * TypeScript line the project installs.
13
+ *
14
+ * Each ttsc release ships one shim tree per supported TypeScript minor line:
15
+ * the 7.0 tree over `github.com/microsoft/typescript-go` and the 7.1 bridges
16
+ * and facades over `github.com/microsoft/TypeScript/tsc`. A plugin, the
17
+ * in-memory compiler host and the linked plugin host all build against the
18
+ * target of the project's line, so their checker is the compiler the project's
19
+ * own `tsc` runs. A line newer than every target builds with the newest one,
20
+ * after a warning; a version ttsc cannot read builds with the 7.0 target, which
21
+ * every installation ships.
22
+ *
23
+ * @evidence contracts/common.md#principled-implementation The target follows the installed compiler's major.minor line, the unit at which the shim API is audited; a prerelease of a line such as 7.1.0-dev belongs to that line. A newer line falls back to the newest audited target rather than to an unaudited commit.
24
+ * @evidence contracts/common.md#clear-and-simple-design One namespace owns line parsing, version reading and the target's build tag, leaving overlay discovery to SourcePluginWorkspace and builds to buildSourcePlugin.
25
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No project, plugin or fixture name selects a target; only the compiler version does.
26
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the supported lines, the newer-line fallback and the unreadable-version default.
27
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The namespace declaration itself performs no native operation; its members state their own boundaries.
28
+ * @evidenceExclude contracts/performance.md#efficient-algorithms The namespace declaration executes nothing.
29
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The namespace declaration coordinates no work.
30
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The namespace declaration retains nothing.
31
+ */
32
+ export namespace CompilerTarget {
33
+ /**
34
+ * A supported compiler line: the major.minor of the TypeScript releases one
35
+ * shipped shim tree targets.
36
+ *
37
+ * @evidence contracts/common.md#principled-implementation Each member names a line whose shims this release ships and audits.
38
+ * @evidence contracts/common.md#clear-and-simple-design A closed union lets every switch over targets be checked for completeness.
39
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Members are shipped lines, not installed versions.
40
+ * @evidence contracts/common.md#meaningful-documentation Native prose states what a member names.
41
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation A type performs no native operation.
42
+ * @evidenceExclude contracts/performance.md#efficient-algorithms A type executes nothing.
43
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work A type coordinates no work.
44
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type retains nothing.
45
+ */
46
+ export type Line = "7.0" | "7.1";
47
+
48
+ /** The newest supported line, which a newer installed line falls back to. */
49
+ export const NEWEST: Line = "7.1";
50
+
51
+ /**
52
+ * The build tag a 7.1 build compiles with; 7.0 builds carry none, so a file
53
+ * marked `!ttsc_typescript_7_1` is the 7.0 side.
54
+ */
55
+ export const TYPESCRIPT_7_1_TAG = "ttsc_typescript_7_1";
56
+
57
+ /**
58
+ * The line a compiler version belongs to, and whether that version is newer
59
+ * than every supported line. A version without a readable major.minor maps to
60
+ * 7.0.
61
+ *
62
+ * @evidence contracts/common.md#principled-implementation Reads the leading major.minor of a semver-shaped version, so a prerelease such as 7.1.0-dev.20261019.1 maps to its own line; 7.0 and 7.1 map to themselves, and any later line is newer than the newest target.
63
+ * @evidence contracts/common.md#clear-and-simple-design One pure mapping serves both the manifest and the custom-binary version source.
64
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Unreadable text maps to the shipped 7.0 target instead of being guessed.
65
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the prerelease, newer-line and unreadable cases.
66
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation The mapping reads its argument only.
67
+ * @evidence contracts/performance.md#efficient-algorithms One anchored regular-expression match over the version text.
68
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The pure mapping coordinates no shared work.
69
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The mapping retains nothing.
70
+ */
71
+ export function lineOf(version: string): { line: Line; newer: boolean } {
72
+ const match = /^\s*(?:Version\s+)?(\d+)\.(\d+)/.exec(version);
73
+ if (match === null) return { line: "7.0", newer: false };
74
+ const major = Number(match[1]);
75
+ const minor = Number(match[2]);
76
+ if (major === 7 && minor === 0) return { line: "7.0", newer: false };
77
+ if (major === 7 && minor === 1) return { line: "7.1", newer: false };
78
+ if (major < 7) return { line: "7.0", newer: false };
79
+ return { line: NEWEST, newer: true };
80
+ }
81
+
82
+ /**
83
+ * The target for a project: the line of the TypeScript compiler it installs,
84
+ * or of `TTSC_TSGO_BINARY` when that names a custom compiler. A version newer
85
+ * than every target selects the newest and warns once per version on stderr.
86
+ *
87
+ * @evidence contracts/common.md#principled-implementation resolveTsgo locates the same compiler the project's build runs; its manifest version is used, and a custom binary is asked for --version since it has no manifest. An unresolvable compiler maps to the 7.0 default, leaving the build's own resolution to report it.
88
+ * @evidence contracts/common.md#clear-and-simple-design Version reading stays here and line mapping in lineOf; callers receive only the line.
89
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The project's real compiler decides the target; no fixture name or path pattern does.
90
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the two version sources and the warning.
91
+ * @evidence contracts/portability.md#os-neutral-implementation resolveTsgo and spawnNative own the native lookup and process launch; the version text is read without shell interpretation.
92
+ * @evidence contracts/performance.md#efficient-algorithms A manifest version costs resolveTsgo's lookup; only a custom binary adds one --version process.
93
+ * @evidence contracts/performance.md#reuse-equivalent-work Custom-binary versions are remembered per binary path for the process, since the binary at a path does not change its line mid-process; manifest versions are read afresh because projects differ.
94
+ * @evidence contracts/performance.md#bound-retention-and-release-resources The remembered map grows with distinct custom binary paths and the warned set with distinct newer versions, both for the process lifetime; the spawned process is synchronous and released on return.
95
+ */
96
+ export function resolve(projectRoot: string, env: NodeJS.ProcessEnv): Line {
97
+ const version = installedVersion(projectRoot, env);
98
+ const { line, newer } = lineOf(version);
99
+ if (newer && !warned.has(version)) {
100
+ warned.add(version);
101
+ process.stderr.write(
102
+ `ttsc: TypeScript ${version} is newer than every compiler target this ttsc supports; ` +
103
+ `using the TypeScript ${line} compiler target.\n`,
104
+ );
105
+ }
106
+ return line;
107
+ }
108
+
109
+ /**
110
+ * The environment a build of line runs Go with: env itself for 7.0, and for
111
+ * 7.1 env with the 7.1 build tag added to the GOFLAGS Go would use, merged
112
+ * into any -tags already set there.
113
+ *
114
+ * A GOFLAGS variable replaces the value `go env -w` stored rather than adding
115
+ * to it, so when env sets no GOFLAGS the stored value is asked of Go from cwd
116
+ * and the tag joins that.
117
+ *
118
+ * @evidence contracts/common.md#principled-implementation GOFLAGS reaches every go command a build runs, so go list, the package-artifact probe and go build select the same tagged files; an existing -tags list gains the tag instead of being replaced, and flags stored by go env -w survive because Go reports them before the variable is set.
119
+ * @evidence contracts/common.md#clear-and-simple-design One environment transform per target replaces threading tags through each command.
120
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Other GOFLAGS entries are kept unchanged and in order, and the stored value comes from Go itself rather than a handwritten environment-file location.
121
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the per-line result, the merge and why the stored value is read.
122
+ * @evidence contracts/portability.md#os-neutral-implementation Go locates and reads its own environment file; resolveGoCompiler, GoToolResolution and spawnGoTool own the native lookup and launch.
123
+ * @evidence contracts/performance.md#efficient-algorithms One pass over the GOFLAGS fields; only a 7.1 build whose env sets no GOFLAGS adds one go env process.
124
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The stored value is read afresh because go env -w can change it between loads.
125
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned environment is a caller-owned copy, and the go env process is synchronous and released on return.
126
+ */
127
+ export function buildEnv(
128
+ env: NodeJS.ProcessEnv,
129
+ line: Line,
130
+ cwd: string,
131
+ ): NodeJS.ProcessEnv {
132
+ if (line !== "7.1") return env;
133
+ const current =
134
+ SidecarEnvironment.read(env, "GOFLAGS") || storedGoFlags(env, cwd);
135
+ const fields = current.split(/\s+/).filter((field) => field !== "");
136
+ let tagged = false;
137
+ const next = fields.map((field) => {
138
+ const match = /^(-{1,2}tags=)(.*)$/.exec(field);
139
+ if (match === null) return field;
140
+ tagged = true;
141
+ const tags = match[2]!.split(",").filter((tag) => tag !== "");
142
+ if (!tags.includes(TYPESCRIPT_7_1_TAG)) tags.push(TYPESCRIPT_7_1_TAG);
143
+ return `${match[1]}${tags.join(",")}`;
144
+ });
145
+ if (!tagged) next.push(`-tags=${TYPESCRIPT_7_1_TAG}`);
146
+ const result = SidecarEnvironment.merge(env);
147
+ SidecarEnvironment.write(result, "GOFLAGS", next.join(" "));
148
+ return result;
149
+ }
150
+
151
+ /**
152
+ * The line a build environment compiles: 7.1 when its GOFLAGS carries the 7.1
153
+ * build tag, otherwise 7.0. A build reads its overlays through this, so the
154
+ * overlaid shim tree is always the one the tagged files were written for.
155
+ *
156
+ * @evidence contracts/common.md#principled-implementation The tag decides which target files Go compiles, so the same tag decides which shim tree they are compiled against; a workspace can never pair 7.1 files with 7.0 shims.
157
+ * @evidence contracts/common.md#clear-and-simple-design The environment a build already carries names its target, so no separate target parameter is threaded through package selection and builds.
158
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Only the Go-defined -tags fields are read; other GOFLAGS text cannot select a target.
159
+ * @evidence contracts/common.md#meaningful-documentation Native prose states the tag rule and why builds read it.
160
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation GOFLAGS is a Go-defined space-separated value; the reading touches no native resource.
161
+ * @evidence contracts/performance.md#efficient-algorithms One pass over the GOFLAGS fields.
162
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The pure reading coordinates no shared work.
163
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The reading retains nothing.
164
+ */
165
+ export function ofEnv(env: NodeJS.ProcessEnv): Line {
166
+ const flags = SidecarEnvironment.read(env, "GOFLAGS") ?? "";
167
+ for (const field of flags.split(/\s+/)) {
168
+ const match = /^-{1,2}tags=(.*)$/.exec(field);
169
+ if (match !== null && match[1]!.split(",").includes(TYPESCRIPT_7_1_TAG))
170
+ return "7.1";
171
+ }
172
+ return "7.0";
173
+ }
174
+
175
+ /**
176
+ * GOFLAGS without the 7.1 build tag ttsc adds: the tag leaves every -tags
177
+ * list, an emptied list leaves the flags, and every other field stays in
178
+ * order.
179
+ *
180
+ * @evidence contracts/common.md#principled-implementation The target tag is ttsc's own selection, not the caller's Go environment; the environment digest of a source state omits it so a reader with the caller's environment reproduces the state, while the build key still separates targets through their overlay modules.
181
+ * @evidence contracts/common.md#clear-and-simple-design The inverse of buildEnv's merge lives beside it, so the two cannot disagree on the tag or the -tags syntax.
182
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Only the exact ttsc tag is removed; every other tag and flag is kept.
183
+ * @evidence contracts/common.md#meaningful-documentation Native prose states what is removed and what is kept.
184
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation GOFLAGS is a Go-defined space-separated value; the transform touches no native resource.
185
+ * @evidence contracts/performance.md#efficient-algorithms One pass over the GOFLAGS fields.
186
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work The pure transform coordinates no shared work.
187
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The transform retains nothing.
188
+ */
189
+ export function withoutTag(flags: string): string {
190
+ return flags
191
+ .split(/\s+/)
192
+ .filter((field) => field !== "")
193
+ .flatMap((field) => {
194
+ const match = /^(-{1,2}tags=)(.*)$/.exec(field);
195
+ if (match === null) return [field];
196
+ const tags = match[2]!
197
+ .split(",")
198
+ .filter((tag) => tag !== "" && tag !== TYPESCRIPT_7_1_TAG);
199
+ return tags.length === 0 ? [] : [`${match[1]}${tags.join(",")}`];
200
+ })
201
+ .join(" ");
202
+ }
203
+
204
+ /** The GOFLAGS Go reports from cwd, or empty when Go cannot answer. */
205
+ function storedGoFlags(env: NodeJS.ProcessEnv, cwd: string): string {
206
+ const goBinary = GoToolResolution.resolveGoToolForBuild(
207
+ resolveGoCompiler(env).binary,
208
+ env,
209
+ cwd,
210
+ );
211
+ const result = spawnGoTool(goBinary, ["env", "GOFLAGS"], {
212
+ cwd,
213
+ encoding: "utf8",
214
+ env: GoSourceInputs.goBuildEnv(goBinary, undefined, env),
215
+ windowsHide: true,
216
+ });
217
+ return result.error === undefined && result.status === 0
218
+ ? result.stdout.trim()
219
+ : "";
220
+ }
221
+
222
+ const warned = new Set<string>();
223
+ const customVersions = new Map<string, string>();
224
+
225
+ function installedVersion(
226
+ projectRoot: string,
227
+ env: NodeJS.ProcessEnv,
228
+ ): string {
229
+ let tsgo: ReturnType<typeof resolveTsgo>;
230
+ try {
231
+ tsgo = resolveTsgo({ cwd: projectRoot, env });
232
+ } catch {
233
+ return "unknown";
234
+ }
235
+ if (tsgo.version !== "custom") return tsgo.version;
236
+ const known = customVersions.get(tsgo.binary);
237
+ if (known !== undefined) return known;
238
+ const result = spawnNative(tsgo.binary, ["--version"], {
239
+ cwd: projectRoot,
240
+ env,
241
+ });
242
+ const version =
243
+ result.error === undefined && result.status === 0
244
+ ? outputText(result.stdout).trim()
245
+ : "unknown";
246
+ customVersions.set(tsgo.binary, version);
247
+ return version;
248
+ }
249
+ }
@@ -6,6 +6,7 @@ import { SidecarEnvironment } from "../../../compiler/internal/sharedHost/Sideca
6
6
  import { OwnedSynchronousProcess } from "../../../internal/OwnedSynchronousProcess";
7
7
  import { SourceNativeRetirement } from "../../../internal/SourceNativeRetirement";
8
8
  import { createCanonicalTempDirectory } from "../../../internal/createCanonicalTempDirectory";
9
+ import { CompilerTarget } from "./CompilerTarget";
9
10
  import { GoSourceInputs } from "./GoSourceInputs";
10
11
  import { GoToolResolution } from "./GoToolResolution";
11
12
  import { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
@@ -211,7 +212,7 @@ export namespace NativeSourcePackages {
211
212
  );
212
213
  SourcePluginWorkspace.writeGoWork(
213
214
  scratch,
214
- SourcePluginWorkspace.findTtscOverlayDirs(),
215
+ SourcePluginWorkspace.findTtscOverlayDirs(CompilerTarget.ofEnv(env)),
215
216
  goBinary,
216
217
  opts.pluginName,
217
218
  env,
@@ -228,7 +229,7 @@ export namespace NativeSourcePackages {
228
229
  identity !== undefined &&
229
230
  copiesKeyed &&
230
231
  observed.every((input) => input.Error === undefined) &&
231
- JSON.stringify(overlayDigests(opts.identities)) ===
232
+ JSON.stringify(overlayDigests(env, opts.identities)) ===
232
233
  JSON.stringify(identity.overlays)
233
234
  )
234
235
  PluginLoadAnswers.write(
@@ -622,7 +623,9 @@ function selectionIdentity(
622
623
  : ["go.mod", "go.sum"].map((name) =>
623
624
  fileDigest(path.join(host, name)),
624
625
  ),
625
- overlays: SourcePluginWorkspace.findTtscOverlayDirs().map(directory),
626
+ overlays: SourcePluginWorkspace.findTtscOverlayDirs(
627
+ CompilerTarget.ofEnv(env),
628
+ ).map(directory),
626
629
  entries: opts.packages.map((input) => [
627
630
  input.entry,
628
631
  input.name ?? null,
@@ -637,9 +640,12 @@ function selectionIdentity(
637
640
 
638
641
  /** The digest of every overlay module, in the generated workspace's order. */
639
642
  function overlayDigests(
643
+ env: NodeJS.ProcessEnv,
640
644
  identities: PluginContentIdentities.Store | undefined,
641
645
  ): string[] {
642
- return SourcePluginWorkspace.findTtscOverlayDirs().map((directory) =>
646
+ return SourcePluginWorkspace.findTtscOverlayDirs(
647
+ CompilerTarget.ofEnv(env),
648
+ ).map((directory) =>
643
649
  PluginContentIdentities.sourceDirectory(identities, directory),
644
650
  );
645
651
  }
@@ -77,7 +77,7 @@ export namespace SourcePluginAdmission {
77
77
  * Identify compiler/shim module names whose replacement ttsc owns. This is
78
78
  * module-name policy, not a lookup of a physical Go module.
79
79
  *
80
- * @evidence contracts/common.md#principled-implementation Exact ttsc/compiler roots and the compiler shim namespace retain the existing managed-module discriminants.
80
+ * @evidence contracts/common.md#principled-implementation Exact ttsc and compiler roots of both targets and every shim namespace are the managed-module discriminants.
81
81
  * @evidence contracts/common.md#clear-and-simple-design Both replacement rejection and workspace filtering use this same predicate.
82
82
  * @evidence contracts/common.md#prohibited-implementation-shortcuts Module-name policy does not fabricate filesystem module identity or compiled provenance.
83
83
  * @evidence contracts/common.md#meaningful-documentation Native prose distinguishes module-name classification from physical lookup.
@@ -90,7 +90,33 @@ export namespace SourcePluginAdmission {
90
90
  return (
91
91
  modulePath === "github.com/samchon/ttsc/packages/ttsc" ||
92
92
  modulePath === "github.com/microsoft/typescript-go" ||
93
- modulePath.startsWith("github.com/microsoft/typescript-go/shim/")
93
+ modulePath === "github.com/microsoft/TypeScript/tsc" ||
94
+ isManagedShimModule(modulePath)
95
+ );
96
+ }
97
+
98
+ /** The module-path prefix of the TypeScript 7.1 target's bridges. */
99
+ export const BRIDGE_MODULE_PREFIX =
100
+ "github.com/microsoft/TypeScript/tsc/shim/";
101
+
102
+ /**
103
+ * Identify a ttsc-owned shim module of any compiler target: a 7.0 shim or a
104
+ * 7.1 facade, both `github.com/microsoft/typescript-go/shim/*`, or a 7.1
105
+ * bridge. This is module-name policy, not a lookup of a physical Go module.
106
+ *
107
+ * @evidence contracts/common.md#principled-implementation Both shim namespaces are ttsc-owned module names; a prefix test classifies each.
108
+ * @evidence contracts/common.md#clear-and-simple-design isManagedModule and workspace writing share this predicate.
109
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Module-name policy does not fabricate filesystem module identity.
110
+ * @evidence contracts/common.md#meaningful-documentation Native prose names the three shim kinds.
111
+ * @evidenceExclude contracts/portability.md#os-neutral-implementation Go module identifiers are supplied strings, not native filesystem paths.
112
+ * @evidenceExclude contracts/performance.md#efficient-algorithms Two prefix comparisons own no population-processing strategy.
113
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work Current module text is classified without retained lookup results.
114
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources No native handle, module registry or task is acquired or retained.
115
+ */
116
+ export function isManagedShimModule(modulePath: string): boolean {
117
+ return (
118
+ modulePath.startsWith("github.com/microsoft/typescript-go/shim/") ||
119
+ modulePath.startsWith(BRIDGE_MODULE_PREFIX)
94
120
  );
95
121
  }
96
122
 
@@ -5,6 +5,7 @@ import path from "node:path";
5
5
 
6
6
  import { OwnedSynchronousProcess } from "../../../internal/OwnedSynchronousProcess";
7
7
  import { runtimeExecutableIdentity } from "../../../internal/runtimeExecutableIdentity";
8
+ import type { CompilerTarget } from "./CompilerTarget";
8
9
  import { GoEnvironmentReading } from "./GoEnvironmentReading";
9
10
  import { GoSourceInputs } from "./GoSourceInputs";
10
11
  import { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
@@ -86,26 +87,44 @@ export namespace SourcePluginWorkspace {
86
87
  ): void {
87
88
  validateSourceReplacements(scratchDir, useDirs, goModReader, pluginName);
88
89
  const sourceInfo = goModReader.read(scratchDir);
89
- const effectiveUseDirs =
90
- sourceInfo.modulePath === TTSC_GO_MODULE_PATH
91
- ? useDirs.filter((dir) => {
92
- OwnedSynchronousProcess.checkpoint();
93
- const modulePath = goModReader.read(dir).modulePath;
94
- return (
95
- modulePath !== null &&
96
- !SourcePluginAdmission.isManagedModule(modulePath)
97
- );
98
- })
99
- : useDirs;
90
+ // A TypeScript 7.1 target overlays bridges and facades. Each facade shares
91
+ // its module path with a 7.0 shim that the ttsc module's own go.mod
92
+ // replaces, so the shims become workspace replacements, which override
93
+ // module replacements, rather than workspace modules.
94
+ const bridged = useDirs.some((dir) =>
95
+ (goModReader.read(dir).modulePath ?? "").startsWith(
96
+ SourcePluginAdmission.BRIDGE_MODULE_PREFIX,
97
+ ),
98
+ );
99
+ const shimReplaceLines: string[] = [];
100
+ const effectiveUseDirs = useDirs.filter((dir) => {
101
+ OwnedSynchronousProcess.checkpoint();
102
+ const modulePath = goModReader.read(dir).modulePath;
103
+ if (
104
+ bridged &&
105
+ modulePath !== null &&
106
+ SourcePluginAdmission.isManagedShimModule(modulePath)
107
+ ) {
108
+ shimReplaceLines.push(
109
+ `replace ${modulePath} => ${formatGoWorkPath(dir)}`,
110
+ );
111
+ return false;
112
+ }
113
+ return (
114
+ sourceInfo.modulePath !== TTSC_GO_MODULE_PATH ||
115
+ (modulePath !== null &&
116
+ !SourcePluginAdmission.isManagedModule(modulePath))
117
+ );
118
+ });
100
119
  const useLines = ["\t."];
101
120
  for (const dir of effectiveUseDirs) {
102
121
  OwnedSynchronousProcess.checkpoint();
103
122
  useLines.push(`\t${formatGoWorkPath(dir)}`);
104
123
  }
105
- const replaceLines = sourceBuildWorkspaceReplacements(
106
- effectiveUseDirs,
107
- goModReader,
108
- );
124
+ const replaceLines = [
125
+ ...sourceBuildWorkspaceReplacements(effectiveUseDirs, goModReader),
126
+ ...shimReplaceLines.sort(),
127
+ ];
109
128
  const replaceBlock =
110
129
  replaceLines.length === 0 ? "" : `\n\n${replaceLines.join("\n")}\n`;
111
130
  const goWork = `use (\n${useLines.join("\n")}\n)${replaceBlock}`;
@@ -683,9 +702,11 @@ export namespace SourcePluginWorkspace {
683
702
  }
684
703
 
685
704
  /**
686
- * Discover the installed native compiler/shim module overlays.
705
+ * Discover the installed native compiler/shim module overlays of a compiler
706
+ * target: the ttsc module and, for 7.0, the shim tree, or for 7.1 its bridges
707
+ * and facades. Omitting line selects 7.0.
687
708
  *
688
- * @evidence contracts/common.md#principled-implementation Existing ttsc and shim go.mod files enter overlay selection under shared directory pruning policy.
709
+ * @evidence contracts/common.md#principled-implementation Existing ttsc and target shim go.mod files enter overlay selection under shared directory pruning policy; each line's tree is a separate directory, so one target's modules never enter another's workspace.
689
710
  * @evidence contracts/common.md#clear-and-simple-design One recursive walker gathers modules and one sort stabilizes ordering.
690
711
  * @evidence contracts/common.md#prohibited-implementation-shortcuts No guessed list of shim modules replaces current filesystem discovery.
691
712
  * @evidence contracts/common.md#meaningful-documentation Native prose states this operation's authority and delegated boundaries; fields retain separate native comments.
@@ -694,13 +715,18 @@ export namespace SourcePluginWorkspace {
694
715
  * @evidence contracts/performance.md#reuse-equivalent-work Each call observes installed layout afresh; contextual module readers separately reuse manifest content observations.
695
716
  * @evidence contracts/performance.md#bound-retention-and-release-resources Directory arrays/path strings live only for this call/result; synchronous fs calls retain no open handle.
696
717
  */
697
- export function findTtscOverlayDirs(): readonly string[] {
718
+ export function findTtscOverlayDirs(
719
+ line: CompilerTarget.Line = "7.0",
720
+ ): readonly string[] {
698
721
  const ttscRoot = path.resolve(__dirname, "..", "..", "..", "..");
699
722
  const dirs: string[] = [];
700
723
  if (fs.existsSync(path.join(ttscRoot, "go.mod"))) {
701
724
  dirs.push(ttscRoot);
702
725
  }
703
- const shimRoot = path.join(ttscRoot, "shim");
726
+ const shimRoot =
727
+ line === "7.0"
728
+ ? path.join(ttscRoot, "shim")
729
+ : path.join(ttscRoot, "targets", line);
704
730
  if (fs.existsSync(shimRoot)) {
705
731
  walkForGoMod(shimRoot, dirs);
706
732
  }
@@ -8,6 +8,7 @@ import { OwnedSynchronousProcess } from "../../../internal/OwnedSynchronousProce
8
8
  import { SourceNativeRetirement } from "../../../internal/SourceNativeRetirement";
9
9
  import { createCanonicalTempDirectory } from "../../../internal/createCanonicalTempDirectory";
10
10
  import { runHoldingLock } from "../../../internal/runHoldingLock";
11
+ import { CompilerTarget } from "./CompilerTarget";
11
12
  import { GoSourceInputs } from "./GoSourceInputs";
12
13
  import { GoToolResolution } from "./GoToolResolution";
13
14
  import type { IPluginModuleReplaceDirectory } from "./IPluginModuleReplaceDirectory";
@@ -208,7 +209,8 @@ function buildSourcePluginAttempt(
208
209
  OwnedSynchronousProcess.checkpoint();
209
210
  const { dir, entry, source } = resolveSourceBuildTarget(opts);
210
211
  const overlayDirs = [
211
- ...(opts.overlayDirs ?? SourcePluginWorkspace.findTtscOverlayDirs()),
212
+ ...(opts.overlayDirs ??
213
+ SourcePluginWorkspace.findTtscOverlayDirs(CompilerTarget.ofEnv(env))),
212
214
  ].sort();
213
215
  const contributors = opts.contributors ?? [];
214
216
  const compiler = resolveGoCompiler(env);