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.
- package/README.md +2 -0
- package/cmd/ttsc/api_compile.go +3 -2
- package/cmd/ttsc/api_transform.go +1 -1
- package/cmd/ttsc/build.go +5 -4
- package/cmd/ttsc-cache/account.go +16 -0
- package/cmd/ttsc-cache/account_test.go +91 -0
- package/cmd/ttsc-cache/main.go +1 -1
- package/cmd/ttsc-cache/protocol_test.go +2 -2
- package/cmd/ttsc-cache/publisher_seal_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_failure_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_test.go +2 -2
- package/cmd/ttsc-cache/store.go +5 -0
- package/cmd/ttsc-cache/tuple.go +6 -2
- package/cmd/ttsc-cache/tuple_test.go +1 -1
- package/cmd/ttscgraph/main.go +6 -1
- package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +6 -1
- package/cmd/ttscgraph/serve.go +22 -20
- package/cmd/ttscgraph/serve_alternative_members_and_reads_refresh_test.go +95 -0
- package/cmd/ttscgraph/serve_shards.go +26 -15
- package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +1 -1
- package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +5 -5
- package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +8 -8
- package/cmd/ttscgraph/serve_source_encoding_test.go +2 -2
- package/driver/build_information_uses_selected_output_identity_test.go +5 -4
- package/driver/check_observations.go +1 -1
- package/driver/config_discovery.go +5 -1
- package/driver/declaration_shape.go +15 -21
- package/driver/diagnostics_preamble.go +2 -2
- package/driver/emit_containment.go +11 -14
- package/driver/emit_plugin.go +51 -43
- package/driver/emit_plugin_output.go +6 -5
- package/driver/emit_provenance.go +12 -15
- package/driver/graph.go +8 -8
- package/driver/host.go +15 -5
- package/driver/input_observation.go +22 -21
- package/driver/input_observation_test.go +11 -10
- package/driver/overlay.go +11 -11
- package/driver/program.go +102 -51
- package/driver/resolution_candidates.go +50 -32
- package/driver/resolution_candidates_test.go +18 -5
- package/driver/rewrite.go +11 -13
- package/driver/session.go +13 -7
- package/driver/target_ts70.go +85 -0
- package/driver/target_ts71.go +97 -0
- package/driver/transform_dependencies.go +1 -1
- package/driver/transform_source_map.go +21 -20
- package/go.mod +3 -3
- package/go.sum +4 -4
- package/internal/graph/alternative_member_declarations_resolve_uses_test.go +145 -0
- package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/build.go +75 -33
- package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +4 -4
- package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +1 -1
- package/internal/graph/declaration_members.go +143 -0
- package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +3 -3
- package/internal/graph/doc_tags.go +2 -2
- package/internal/graph/dump_paths.go +6 -5
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +1 -1
- package/internal/graph/edges.go +151 -68
- package/internal/graph/edges_cover_class_level_references_test.go +5 -5
- package/internal/graph/enum_initializer_calls_are_edges_test.go +2 -2
- package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +6 -6
- package/internal/graph/exports.go +6 -6
- package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +2 -2
- package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +1 -1
- package/internal/graph/function_locals_do_not_collide_test.go +3 -3
- package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +5 -5
- package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +2 -2
- package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +3 -3
- package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +3 -3
- package/internal/graph/literals.go +3 -3
- package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +2 -2
- package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +4 -4
- package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +2 -2
- package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +1 -1
- package/internal/graph/literals_resolve_through_alias_indirection_test.go +3 -3
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +7 -7
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +19 -19
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +11 -11
- package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +2 -2
- package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +7 -7
- package/internal/graph/namespace_private_declarations_keep_lexical_identity_test.go +85 -0
- package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +2 -2
- package/internal/graph/object_literal_declarations_resolve_calls_test.go +9 -9
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +1 -1
- package/internal/graph/overload_implementation_replaces_signature_test.go +2 -2
- package/internal/graph/property_member_edges_remain_owner_visible_test.go +6 -6
- package/internal/graph/resolve.go +37 -12
- package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +6 -6
- package/internal/graph/source.go +1 -1
- package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +7 -7
- package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +2 -2
- package/internal/graph/value_access_edges_cover_properties_test.go +5 -5
- package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +3 -3
- package/internal/graph/value_call_edges_cover_jsx_components_test.go +2 -2
- package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +3 -3
- package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +2 -2
- package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +4 -4
- package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +3 -3
- package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +2 -2
- package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +4 -4
- package/internal/graph/value_reads_cover_expression_positions_test.go +88 -0
- package/lib/compiler/internal/buildNativeCompiler.d.ts +5 -2
- package/lib/compiler/internal/buildNativeCompiler.js +12 -4
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -1
- package/lib/flags/COMPILER_OPTIONS.js +1079 -149
- package/lib/flags/COMPILER_OPTIONS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -1
- package/lib/flags/CompilerOptionSpec.d.ts +9 -2
- package/lib/internal/pluginSource.d.ts +1 -0
- package/lib/internal/pluginSource.js +1 -0
- package/lib/internal/pluginSource.js.map +1 -1
- package/lib/launcher/internal/TypeScriptSyncApi.d.ts +140 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js +99 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootInMemory.d.ts +80 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js +253 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootProject.d.ts +22 -18
- package/lib/launcher/internal/buildSingleRootProject.js +27 -18
- package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
- package/lib/launcher/internal/compilerArgsAsConfigOptions.d.ts +39 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js +115 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js.map +1 -0
- package/lib/plugin/CapabilityPluginResolver.js +3 -0
- package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
- package/lib/plugin/internal/load/loadProjectPlugins.js +6 -2
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
- package/lib/plugin/internal/source/CompilerTarget.d.ts +127 -0
- package/lib/plugin/internal/source/CompilerTarget.js +231 -0
- package/lib/plugin/internal/source/CompilerTarget.js.map +1 -0
- package/lib/plugin/internal/source/NativeSourcePackages.js +6 -5
- package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +18 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.js +24 -2
- package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +6 -3
- package/lib/plugin/internal/source/SourcePluginWorkspace.js +31 -13
- package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js +3 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +9 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
- package/package.json +14 -9
- package/shim/ast/enums_gen.go +1 -0
- package/shim/ast/go.mod +2 -2
- package/shim/ast/go.sum +4 -4
- package/shim/ast/neutral.go +141 -0
- package/shim/astnav/go.mod +2 -2
- package/shim/astnav/go.sum +4 -4
- package/shim/bundled/go.mod +2 -2
- package/shim/bundled/go.sum +4 -4
- package/shim/checker/go.mod +2 -2
- package/shim/checker/go.sum +4 -4
- package/shim/compiler/go.mod +2 -2
- package/shim/compiler/go.sum +4 -4
- package/shim/compiler/neutral.go +213 -0
- package/shim/core/go.mod +2 -2
- package/shim/core/go.sum +4 -4
- package/shim/diagnosticwriter/go.mod +2 -2
- package/shim/diagnosticwriter/go.sum +4 -4
- package/shim/lsp/go.mod +2 -2
- package/shim/lsp/go.sum +4 -4
- package/shim/parser/go.mod +2 -2
- package/shim/parser/go.sum +4 -4
- package/shim/printer/go.mod +2 -2
- package/shim/printer/go.sum +4 -4
- package/shim/scanner/go.mod +2 -2
- package/shim/scanner/go.sum +4 -4
- package/shim/stringutil/go.mod +1 -1
- package/shim/stringutil/go.sum +2 -2
- package/shim/stringutil/shim.go +15 -0
- package/shim/transformers/go.mod +2 -2
- package/shim/transformers/go.sum +4 -4
- package/shim/tsoptions/go.mod +2 -2
- package/shim/tsoptions/go.sum +4 -4
- package/shim/tsoptions/neutral.go +56 -0
- package/shim/tspath/go.mod +1 -1
- package/shim/tspath/go.sum +2 -2
- package/shim/tspath/neutral.go +150 -0
- package/shim/tspath/typed_paths.go +266 -0
- package/shim/vfs/cachedvfs/go.mod +2 -2
- package/shim/vfs/cachedvfs/go.sum +4 -4
- package/shim/vfs/go.mod +2 -2
- package/shim/vfs/go.sum +4 -4
- package/shim/vfs/neutral.go +20 -0
- package/shim/vfs/osvfs/go.mod +2 -2
- package/shim/vfs/osvfs/go.sum +4 -4
- package/src/compiler/internal/buildNativeCompiler.ts +13 -4
- package/src/flags/COMPILER_ENUM_WHITESPACE.ts +1 -1
- package/src/flags/COMPILER_OPTIONS.ts +1080 -150
- package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +1 -1
- package/src/flags/COMPILER_OPTION_KINDS.ts +1 -1
- package/src/flags/CompilerOptionSpec.ts +11 -2
- package/src/internal/pluginSource.ts +1 -0
- package/src/launcher/internal/TypeScriptSyncApi.ts +186 -0
- package/src/launcher/internal/buildSingleRootInMemory.ts +319 -0
- package/src/launcher/internal/buildSingleRootProject.ts +26 -18
- package/src/launcher/internal/compilerArgsAsConfigOptions.ts +112 -0
- package/src/plugin/CapabilityPluginResolver.ts +4 -1
- package/src/plugin/internal/load/loadProjectPlugins.ts +12 -2
- package/src/plugin/internal/source/CompilerTarget.ts +249 -0
- package/src/plugin/internal/source/NativeSourcePackages.ts +10 -4
- package/src/plugin/internal/source/SourcePluginAdmission.ts +28 -2
- package/src/plugin/internal/source/SourcePluginWorkspace.ts +45 -19
- package/src/plugin/internal/source/buildSourcePlugin.ts +3 -1
- package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +9 -1
- package/targets/7.1/bridge/ast/enums_gen.go +174 -0
- package/targets/7.1/bridge/ast/extra-shim.json +4 -0
- package/targets/7.1/bridge/ast/go.mod +14 -0
- package/targets/7.1/bridge/ast/go.sum +20 -0
- package/targets/7.1/bridge/ast/lint.go +1412 -0
- package/targets/7.1/bridge/ast/neutral.go +141 -0
- package/targets/7.1/bridge/ast/parent.go +60 -0
- package/targets/7.1/bridge/ast/safe_text.go +108 -0
- package/targets/7.1/bridge/ast/shim.go +1656 -0
- package/targets/7.1/bridge/ast/surface.go +686 -0
- package/targets/7.1/bridge/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_multi_hop_qualified_name_test.go +47 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_one_hop_qualified_name_test.go +35 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_empty_for_nil_test.go +31 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_identifier_text_test.go +34 -0
- package/targets/7.1/bridge/ast/test/node_text_skips_empty_qualified_left_test.go +60 -0
- package/targets/7.1/bridge/astnav/go.mod +14 -0
- package/targets/7.1/bridge/astnav/go.sum +22 -0
- package/targets/7.1/bridge/astnav/shim.go +24 -0
- package/targets/7.1/bridge/bundled/extra-shim.json +1 -0
- package/targets/7.1/bridge/bundled/go.mod +10 -0
- package/targets/7.1/bridge/bundled/go.sum +10 -0
- package/targets/7.1/bridge/bundled/shim.go +24 -0
- package/targets/7.1/bridge/checker/enums_gen.go +150 -0
- package/targets/7.1/bridge/checker/extra-shim.json +37 -0
- package/targets/7.1/bridge/checker/go.mod +15 -0
- package/targets/7.1/bridge/checker/go.sum +24 -0
- package/targets/7.1/bridge/checker/node_builder_fields_gen.go +19 -0
- package/targets/7.1/bridge/checker/shim.go +1390 -0
- package/targets/7.1/bridge/compiler/contentmapper_process.go +70 -0
- package/targets/7.1/bridge/compiler/emit_sourcemap.go +296 -0
- package/targets/7.1/bridge/compiler/emitassemble.go +81 -0
- package/targets/7.1/bridge/compiler/emithook.go +44 -0
- package/targets/7.1/bridge/compiler/extra-shim.json +4 -0
- package/targets/7.1/bridge/compiler/go.mod +15 -0
- package/targets/7.1/bridge/compiler/go.sum +24 -0
- package/targets/7.1/bridge/compiler/incremental.go +185 -0
- package/targets/7.1/bridge/compiler/neutral.go +256 -0
- package/targets/7.1/bridge/compiler/resolution.go +571 -0
- package/targets/7.1/bridge/compiler/shim.go +70 -0
- package/targets/7.1/bridge/core/enums_gen.go +15 -0
- package/targets/7.1/bridge/core/extra-shim.json +4 -0
- package/targets/7.1/bridge/core/go.mod +7 -0
- package/targets/7.1/bridge/core/go.sum +8 -0
- package/targets/7.1/bridge/core/modulekind.go +19 -0
- package/targets/7.1/bridge/core/shim.go +272 -0
- package/targets/7.1/bridge/diagnosticwriter/go.mod +14 -0
- package/targets/7.1/bridge/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/bridge/diagnosticwriter/lint.go +411 -0
- package/targets/7.1/bridge/diagnosticwriter/shim.go +56 -0
- package/targets/7.1/bridge/lsp/extra-shim.json +4 -0
- package/targets/7.1/bridge/lsp/go.mod +16 -0
- package/targets/7.1/bridge/lsp/go.sum +26 -0
- package/targets/7.1/bridge/lsp/shim.go +112 -0
- package/targets/7.1/bridge/parser/extra-shim.json +4 -0
- package/targets/7.1/bridge/parser/go.mod +14 -0
- package/targets/7.1/bridge/parser/go.sum +24 -0
- package/targets/7.1/bridge/parser/shim.go +61 -0
- package/targets/7.1/bridge/printer/emithost.go +69 -0
- package/targets/7.1/bridge/printer/go.mod +15 -0
- package/targets/7.1/bridge/printer/go.sum +24 -0
- package/targets/7.1/bridge/printer/shim.go +168 -0
- package/targets/7.1/bridge/printer/sourcemap.go +49 -0
- package/targets/7.1/bridge/scanner/extra-shim.json +4 -0
- package/targets/7.1/bridge/scanner/go.mod +14 -0
- package/targets/7.1/bridge/scanner/go.sum +20 -0
- package/targets/7.1/bridge/scanner/regexp.go +42 -0
- package/targets/7.1/bridge/scanner/shim.go +137 -0
- package/targets/7.1/bridge/stringutil/extra-shim.json +1 -0
- package/targets/7.1/bridge/stringutil/go.mod +5 -0
- package/targets/7.1/bridge/stringutil/go.sum +2 -0
- package/targets/7.1/bridge/stringutil/shim.go +131 -0
- package/targets/7.1/bridge/transformers/go.mod +15 -0
- package/targets/7.1/bridge/transformers/go.sum +24 -0
- package/targets/7.1/bridge/transformers/shim.go +24 -0
- package/targets/7.1/bridge/tsoptions/command_line_raw.go +44 -0
- package/targets/7.1/bridge/tsoptions/extra-shim.json +4 -0
- package/targets/7.1/bridge/tsoptions/go.mod +15 -0
- package/targets/7.1/bridge/tsoptions/go.sum +24 -0
- package/targets/7.1/bridge/tsoptions/neutral.go +47 -0
- package/targets/7.1/bridge/tsoptions/shim.go +193 -0
- package/targets/7.1/bridge/tspath/extra-shim.json +4 -0
- package/targets/7.1/bridge/tspath/go.mod +5 -0
- package/targets/7.1/bridge/tspath/go.sum +6 -0
- package/targets/7.1/bridge/tspath/neutral.go +142 -0
- package/targets/7.1/bridge/tspath/shim.go +382 -0
- package/targets/7.1/bridge/vfs/cachedvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.mod +5 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/cachedvfs/shim.go +12 -0
- package/targets/7.1/bridge/vfs/decode.go +26 -0
- package/targets/7.1/bridge/vfs/decode_test.go +42 -0
- package/targets/7.1/bridge/vfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/neutral.go +23 -0
- package/targets/7.1/bridge/vfs/osvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/osvfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/osvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/osvfs/shim.go +14 -0
- package/targets/7.1/bridge/vfs/shim.go +27 -0
- package/targets/7.1/facade/ast/facade_gen.go +2691 -0
- package/targets/7.1/facade/ast/go.mod +20 -0
- package/targets/7.1/facade/ast/go.sum +20 -0
- package/targets/7.1/facade/astnav/facade_gen.go +15 -0
- package/targets/7.1/facade/astnav/go.mod +22 -0
- package/targets/7.1/facade/astnav/go.sum +22 -0
- package/targets/7.1/facade/bundled/facade_gen.go +32 -0
- package/targets/7.1/facade/bundled/go.mod +21 -0
- package/targets/7.1/facade/bundled/go.sum +10 -0
- package/targets/7.1/facade/checker/facade_gen.go +563 -0
- package/targets/7.1/facade/checker/go.mod +26 -0
- package/targets/7.1/facade/checker/go.sum +24 -0
- package/targets/7.1/facade/compiler/facade_gen.go +198 -0
- package/targets/7.1/facade/compiler/go.mod +41 -0
- package/targets/7.1/facade/compiler/go.sum +24 -0
- package/targets/7.1/facade/core/facade_gen.go +130 -0
- package/targets/7.1/facade/core/go.mod +12 -0
- package/targets/7.1/facade/core/go.sum +8 -0
- package/targets/7.1/facade/diagnosticwriter/facade_gen.go +36 -0
- package/targets/7.1/facade/diagnosticwriter/go.mod +22 -0
- package/targets/7.1/facade/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/facade/lsp/facade_gen.go +31 -0
- package/targets/7.1/facade/lsp/go.mod +19 -0
- package/targets/7.1/facade/lsp/go.sum +26 -0
- package/targets/7.1/facade/parser/facade_gen.go +102 -0
- package/targets/7.1/facade/parser/go.mod +25 -0
- package/targets/7.1/facade/parser/go.sum +24 -0
- package/targets/7.1/facade/printer/facade_gen.go +74 -0
- package/targets/7.1/facade/printer/go.mod +26 -0
- package/targets/7.1/facade/printer/go.sum +24 -0
- package/targets/7.1/facade/scanner/facade_gen.go +191 -0
- package/targets/7.1/facade/scanner/go.mod +25 -0
- package/targets/7.1/facade/scanner/go.sum +20 -0
- package/targets/7.1/facade/stringutil/facade_gen.go +176 -0
- package/targets/7.1/facade/stringutil/go.mod +9 -0
- package/targets/7.1/facade/stringutil/go.sum +2 -0
- package/targets/7.1/facade/transformers/facade_gen.go +12 -0
- package/targets/7.1/facade/transformers/go.mod +18 -0
- package/targets/7.1/facade/transformers/go.sum +24 -0
- package/targets/7.1/facade/tsoptions/facade_gen.go +274 -0
- package/targets/7.1/facade/tsoptions/go.mod +32 -0
- package/targets/7.1/facade/tsoptions/go.sum +24 -0
- package/targets/7.1/facade/tspath/facade_gen.go +550 -0
- package/targets/7.1/facade/tspath/go.mod +9 -0
- package/targets/7.1/facade/tspath/go.sum +6 -0
- package/targets/7.1/facade/vfs/cachedvfs/facade_gen.go +17 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/facade_gen.go +47 -0
- package/targets/7.1/facade/vfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/osvfs/facade_gen.go +20 -0
- package/targets/7.1/facade/vfs/osvfs/go.mod +21 -0
- package/targets/7.1/facade/vfs/osvfs/go.sum +10 -0
- package/tools/gen_facade/committed_facades_match_their_bridges_test.go +57 -0
- package/tools/gen_facade/facade_manifest_points_into_the_bridge_root_test.go +75 -0
- package/tools/gen_facade/facade_spells_internal_types_through_bridge_aliases_test.go +75 -0
- package/tools/gen_facade/facade_types_are_their_bridge_types_test.go +99 -0
- package/tools/gen_facade/go.mod +10 -0
- package/tools/gen_facade/go.sum +8 -0
- package/tools/gen_facade/main.go +734 -0
- package/tools/gen_shims/go.mod +4 -4
- package/tools/gen_shims/go.sum +6 -6
- package/tools/gen_shims/main.go +124 -66
- package/tools/gen_shims/mirror_structs_terminate_on_unexported_cycles_test.go +101 -0
- package/tools/shim_audit/baseline-7.1.json +720 -0
- package/tools/shim_audit/baseline.json +5 -4
- package/tools/shim_audit/go.mod +4 -4
- package/tools/shim_audit/go.sum +6 -6
- package/tools/shim_audit/linkname_signatures.go +178 -0
- package/tools/shim_audit/linkname_signatures_match_their_targets_test.go +64 -0
- package/tools/shim_audit/linkname_targets_follow_the_audited_compiler_test.go +38 -0
- package/tools/shim_audit/main.go +29 -4
- package/tools/shim_audit/neutral_api.go +160 -0
- package/tools/shim_audit/neutral_api_must_match_across_targets_test.go +74 -0
- package/utility/host.go +5 -4
- package/utility/preamble_output.go +15 -15
- package/utility/serve.go +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Code generated by packages/ttsc/tools/gen_facade. DO NOT EDIT.
|
|
2
|
+
|
|
3
|
+
// Package osvfs is the documented github.com/microsoft/typescript-go/shim/vfs/osvfs plugin import path.
|
|
4
|
+
// It aliases every exported identity of github.com/microsoft/TypeScript/tsc/shim/vfs/osvfs, the
|
|
5
|
+
// bridge that reaches the compiler's internal packages.
|
|
6
|
+
package osvfs
|
|
7
|
+
|
|
8
|
+
import (
|
|
9
|
+
tsctspath "github.com/microsoft/TypeScript/tsc/shim/tspath"
|
|
10
|
+
tscvfs "github.com/microsoft/TypeScript/tsc/shim/vfs"
|
|
11
|
+
tscosvfs "github.com/microsoft/TypeScript/tsc/shim/vfs/osvfs"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
func FS() tscvfs.FS {
|
|
15
|
+
return tscosvfs.FS()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func GetGlobalTypingsCacheLocation() tsctspath.RootedDirectoryPath {
|
|
19
|
+
return tscosvfs.GetGlobalTypingsCacheLocation()
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module github.com/microsoft/typescript-go/shim/vfs/osvfs
|
|
2
|
+
|
|
3
|
+
go 1.27
|
|
4
|
+
|
|
5
|
+
require (
|
|
6
|
+
github.com/microsoft/TypeScript/tsc/shim/tspath v0.0.0
|
|
7
|
+
github.com/microsoft/TypeScript/tsc/shim/vfs v0.0.0
|
|
8
|
+
github.com/microsoft/TypeScript/tsc/shim/vfs/osvfs v0.0.0
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
require (
|
|
12
|
+
github.com/microsoft/TypeScript/tsc v0.0.0-20261019224239-28534d760906 // indirect
|
|
13
|
+
golang.org/x/sync v0.23.0 // indirect
|
|
14
|
+
golang.org/x/sys v0.48.0 // indirect
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
replace github.com/microsoft/TypeScript/tsc/shim/vfs => ../../../bridge/vfs
|
|
18
|
+
|
|
19
|
+
replace github.com/microsoft/TypeScript/tsc/shim/vfs/osvfs => ../../../bridge/vfs/osvfs
|
|
20
|
+
|
|
21
|
+
replace github.com/microsoft/TypeScript/tsc/shim/tspath => ../../../bridge/tspath
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
2
|
+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
|
3
|
+
github.com/microsoft/TypeScript/tsc v0.0.0-20261019224239-28534d760906 h1:Wn+Kp4ORyay6jJwvOng7G8pTD6HOP+Fwx8si66Wq7Bk=
|
|
4
|
+
github.com/microsoft/TypeScript/tsc v0.0.0-20261019224239-28534d760906/go.mod h1:28hWKaTYwRARPm0T9Y0XvdvYpU2HtjONzsMqAdYLucY=
|
|
5
|
+
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
|
6
|
+
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
|
7
|
+
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
|
8
|
+
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
|
9
|
+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
|
10
|
+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// Verifies every committed TypeScript 7.1 facade is the generator's output for
|
|
11
|
+
// the current bridges, and no facade outlives its bridge.
|
|
12
|
+
//
|
|
13
|
+
// A bridge edit that adds, renames or removes an export changes the documented
|
|
14
|
+
// plugin surface; this gate makes that drift fail instead of shipping silently.
|
|
15
|
+
//
|
|
16
|
+
// 1. Load every real bridge module below packages/ttsc/targets/7.1/bridge.
|
|
17
|
+
// 2. Render each facade and its go.mod in memory.
|
|
18
|
+
// 3. Compare with the committed files, in both directions.
|
|
19
|
+
//
|
|
20
|
+
// Adapted from Danny Wilson's TypeScript 7.1 port (#1727).
|
|
21
|
+
//
|
|
22
|
+
// @evidence contracts/testing.md#behavioral-verification Runs the production generate over the real bridge modules and compares exact bytes with each committed facade_gen.go and go.mod.
|
|
23
|
+
// @evidence contracts/testing.md#independent-expectations The committed files are the reviewed public surface; the generator must reproduce them rather than the test deriving its expectation from the same run.
|
|
24
|
+
// @evidence contracts/testing.md#distinguishing-cases A stale facade, a missing facade and an orphaned facade without a bridge each fail with their own message.
|
|
25
|
+
// @evidence contracts/testing.md#execution-ownership This tools/gen_facade unit loads the repository's bridge modules through go/packages in its own process and writes no file.
|
|
26
|
+
func TestCommittedFacadesMatchTheirBridges(t *testing.T) {
|
|
27
|
+
target := filepath.Join("..", "..", "targets", "7.1")
|
|
28
|
+
facadeRoot := filepath.Join(target, "facade")
|
|
29
|
+
outputs, err := generate(filepath.Join(target, "bridge"), facadeRoot)
|
|
30
|
+
if err != nil {
|
|
31
|
+
t.Fatal(err)
|
|
32
|
+
}
|
|
33
|
+
generated := map[string]bool{}
|
|
34
|
+
for _, output := range outputs {
|
|
35
|
+
generated[output.path] = true
|
|
36
|
+
current, err := os.ReadFile(output.path)
|
|
37
|
+
if err != nil {
|
|
38
|
+
t.Errorf("missing facade file %s: %v", output.path, err)
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
if !bytes.Equal(current, output.source) {
|
|
42
|
+
t.Errorf("stale facade file %s; run go -C tools/gen_facade run .", output.path)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
err = filepath.WalkDir(facadeRoot, func(path string, entry os.DirEntry, err error) error {
|
|
46
|
+
if err != nil {
|
|
47
|
+
return err
|
|
48
|
+
}
|
|
49
|
+
if name := entry.Name(); !entry.IsDir() && (name == outputName || name == "go.mod") && !generated[path] {
|
|
50
|
+
t.Errorf("facade file %s has no bridge", path)
|
|
51
|
+
}
|
|
52
|
+
return nil
|
|
53
|
+
})
|
|
54
|
+
if err != nil {
|
|
55
|
+
t.Fatal(err)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"os"
|
|
5
|
+
"path/filepath"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
|
|
9
|
+
"golang.org/x/mod/modfile"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Verifies a facade manifest requires and replaces exactly the bridges its
|
|
13
|
+
// facade imports, each replacement relative from the facade into the bridge root.
|
|
14
|
+
//
|
|
15
|
+
// Facades and bridges live in sibling roots of one compiler target. A replace
|
|
16
|
+
// path computed from the facade's own depth alone would point outside the
|
|
17
|
+
// bridge root for a nested facade such as vfs/cachedvfs.
|
|
18
|
+
//
|
|
19
|
+
// 1. Write a nested facade go.mod that still requires and replaces a bridge it
|
|
20
|
+
// no longer imports, beside an unrelated requirement.
|
|
21
|
+
// 2. Build its manifest for the two bridges it now imports.
|
|
22
|
+
// 3. Parse the result and compare its requirements and replacements.
|
|
23
|
+
//
|
|
24
|
+
// @evidence contracts/testing.md#behavioral-verification Calls the production facadeManifest over a real go.mod file and parses its output with x/mod, asserting module, requirements and replacement targets.
|
|
25
|
+
// @evidence contracts/testing.md#independent-expectations The expected replacement paths follow from the authored sibling layout, three levels up from targets/7.1/facade/vfs/cachedvfs and into bridge/, not from the generator's output.
|
|
26
|
+
// @evidence contracts/testing.md#distinguishing-cases A stale bridge requirement and replacement must be dropped, two imported bridges at different depths must be added, and an unrelated requirement must survive.
|
|
27
|
+
// @evidence contracts/testing.md#execution-ownership This tools/gen_facade unit writes one temporary go.mod and reads it in process; it loads no package and starts no process.
|
|
28
|
+
func TestFacadeManifestPointsIntoTheBridgeRoot(t *testing.T) {
|
|
29
|
+
target := t.TempDir()
|
|
30
|
+
bridgeRoot := filepath.Join(target, "bridge")
|
|
31
|
+
facadeDir := filepath.Join(target, "facade", "vfs", "cachedvfs")
|
|
32
|
+
if err := os.MkdirAll(facadeDir, 0o755); err != nil {
|
|
33
|
+
t.Fatal(err)
|
|
34
|
+
}
|
|
35
|
+
manifestPath := filepath.Join(facadeDir, "go.mod")
|
|
36
|
+
stale := bridgePrefix + "tspath"
|
|
37
|
+
if err := os.WriteFile(manifestPath, []byte("module "+facadePrefix+"vfs/cachedvfs\n\ngo 1.27\n\nrequire (\n\t"+stale+" v0.0.0\n\texample.com/kept v1.2.3\n)\n\nreplace "+stale+" => ../../../bridge/tspath\n"), 0o644); err != nil {
|
|
38
|
+
t.Fatal(err)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
source, err := facadeManifest(manifestPath, "vfs/cachedvfs", bridgeRoot, []string{bridgePrefix + "vfs/cachedvfs", bridgePrefix + "vfs"})
|
|
42
|
+
if err != nil {
|
|
43
|
+
t.Fatal(err)
|
|
44
|
+
}
|
|
45
|
+
file, err := modfile.Parse(manifestPath, source, nil)
|
|
46
|
+
if err != nil {
|
|
47
|
+
t.Fatal(err)
|
|
48
|
+
}
|
|
49
|
+
requires := map[string]string{}
|
|
50
|
+
for _, require := range file.Require {
|
|
51
|
+
requires[require.Mod.Path] = require.Mod.Version
|
|
52
|
+
}
|
|
53
|
+
replaces := map[string]string{}
|
|
54
|
+
for _, replace := range file.Replace {
|
|
55
|
+
replaces[replace.Old.Path] = replace.New.Path
|
|
56
|
+
}
|
|
57
|
+
want := map[string]string{
|
|
58
|
+
bridgePrefix + "vfs/cachedvfs": "../../../bridge/vfs/cachedvfs",
|
|
59
|
+
bridgePrefix + "vfs": "../../../bridge/vfs",
|
|
60
|
+
}
|
|
61
|
+
for bridge, path := range want {
|
|
62
|
+
if requires[bridge] != "v0.0.0" || replaces[bridge] != path {
|
|
63
|
+
t.Errorf("%s: require %q, replace %q; want v0.0.0 and %q", bridge, requires[bridge], replaces[bridge], path)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if _, ok := requires[stale]; ok {
|
|
67
|
+
t.Errorf("stale bridge requirement survived:\n%s", source)
|
|
68
|
+
}
|
|
69
|
+
if _, ok := replaces[stale]; ok || len(replaces) != len(want) {
|
|
70
|
+
t.Errorf("replacements = %v, want only %v", replaces, want)
|
|
71
|
+
}
|
|
72
|
+
if requires["example.com/kept"] != "v1.2.3" || !strings.HasPrefix(string(source), "module "+facadePrefix+"vfs/cachedvfs") {
|
|
73
|
+
t.Errorf("unrelated lines changed:\n%s", source)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"go/token"
|
|
5
|
+
"go/types"
|
|
6
|
+
"strings"
|
|
7
|
+
"testing"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// Verifies the facade names a compiler-internal type only through a bridge
|
|
11
|
+
// alias and degrades exactly where Go cannot spell a signature.
|
|
12
|
+
//
|
|
13
|
+
// Authored go/types packages stand in for one internal package and one bridge,
|
|
14
|
+
// so the cases isolate the printer's naming policy from module loading.
|
|
15
|
+
//
|
|
16
|
+
// 1. Declare internal Node and Hidden types, and a bridge aliasing only Node.
|
|
17
|
+
// 2. Give the bridge functions over Node, over Hidden, and a generic over Hidden.
|
|
18
|
+
// 3. Render the facade and assert each spelling or the generation failure.
|
|
19
|
+
//
|
|
20
|
+
// @evidence contracts/testing.md#behavioral-verification Calls the production renderFacade and newAliasIndex and asserts the exact forwarded function, alias, held-variable and failure outputs.
|
|
21
|
+
// @evidence contracts/testing.md#independent-expectations Literal facade lines and the unexposed type's name are written from the facade contract, not derived from generator output.
|
|
22
|
+
// @evidence contracts/testing.md#distinguishing-cases Covers an aliased internal parameter, an unaliased internal parameter in a non-generic function, and the same type in a generic function, each with a different required result.
|
|
23
|
+
// @evidence contracts/testing.md#execution-ownership This tools/gen_facade source unit builds packages in memory in one Go process; it loads no module, writes no file and starts no process.
|
|
24
|
+
func TestFacadeSpellsInternalTypesThroughBridgeAliases(t *testing.T) {
|
|
25
|
+
internal := types.NewPackage(internalPrefix+"ast", "ast")
|
|
26
|
+
node := types.NewNamed(types.NewTypeName(token.NoPos, internal, "Node", nil), types.NewStruct(nil, nil), nil)
|
|
27
|
+
internal.Scope().Insert(node.Obj())
|
|
28
|
+
hidden := types.NewNamed(types.NewTypeName(token.NoPos, internal, "Hidden", nil), types.NewStruct(nil, nil), nil)
|
|
29
|
+
internal.Scope().Insert(hidden.Obj())
|
|
30
|
+
|
|
31
|
+
newBridge := func(withGeneric bool) bridge {
|
|
32
|
+
pkg := types.NewPackage(bridgePrefix+"ast", "ast")
|
|
33
|
+
alias := types.NewTypeName(token.NoPos, pkg, "Node", nil)
|
|
34
|
+
types.NewAlias(alias, node)
|
|
35
|
+
pkg.Scope().Insert(alias)
|
|
36
|
+
param := func(typ types.Type) *types.Tuple {
|
|
37
|
+
return types.NewTuple(types.NewVar(token.NoPos, pkg, "n", typ))
|
|
38
|
+
}
|
|
39
|
+
insertFunc := func(name string, sig *types.Signature) {
|
|
40
|
+
pkg.Scope().Insert(types.NewFunc(token.NoPos, pkg, name, sig))
|
|
41
|
+
}
|
|
42
|
+
insertFunc("Visit", types.NewSignatureType(nil, nil, nil, param(types.NewPointer(node)), types.NewTuple(types.NewVar(token.NoPos, pkg, "", types.Typ[types.Bool])), false))
|
|
43
|
+
insertFunc("Peek", types.NewSignatureType(nil, nil, nil, param(types.NewPointer(hidden)), nil, false))
|
|
44
|
+
if withGeneric {
|
|
45
|
+
typeParam := types.NewTypeParam(types.NewTypeName(token.NoPos, pkg, "T", nil), types.Universe.Lookup("any").Type())
|
|
46
|
+
insertFunc("Map", types.NewSignatureType(nil, nil, []*types.TypeParam{typeParam}, param(types.NewPointer(hidden)), types.NewTuple(types.NewVar(token.NoPos, pkg, "", typeParam)), false))
|
|
47
|
+
}
|
|
48
|
+
return bridge{rel: "ast", pkg: pkg}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
plain := newBridge(false)
|
|
52
|
+
source, _, err := renderFacade(plain, newAliasIndex([]bridge{plain}))
|
|
53
|
+
if err != nil {
|
|
54
|
+
t.Fatal(err)
|
|
55
|
+
}
|
|
56
|
+
for _, want := range []string{
|
|
57
|
+
`tscast "github.com/microsoft/TypeScript/tsc/shim/ast"`,
|
|
58
|
+
"type Node = tscast.Node",
|
|
59
|
+
"func Visit(p0 *tscast.Node) bool {\n return tscast.Visit(p0)\n}",
|
|
60
|
+
"// exposes (" + internalPrefix + "ast.Hidden).\nvar Peek = tscast.Peek",
|
|
61
|
+
} {
|
|
62
|
+
if !strings.Contains(string(source), want) {
|
|
63
|
+
t.Errorf("facade lacks %q:\n%s", want, source)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if strings.Contains(string(source), `"`+internalPrefix) {
|
|
67
|
+
t.Errorf("facade imports the internal package:\n%s", source)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
generic := newBridge(true)
|
|
71
|
+
_, _, err = renderFacade(generic, newAliasIndex([]bridge{generic}))
|
|
72
|
+
if err == nil || !strings.Contains(err.Error(), bridgePrefix+"ast.Map: cannot name "+internalPrefix+"ast.Hidden") {
|
|
73
|
+
t.Fatalf("generic function over an unexposed type: got %v", err)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"go/types"
|
|
5
|
+
"os"
|
|
6
|
+
"path/filepath"
|
|
7
|
+
"testing"
|
|
8
|
+
|
|
9
|
+
"golang.org/x/tools/go/packages"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Verifies each documented TypeScript 7.1 import path names the bridge's own
|
|
13
|
+
// types rather than copies of them.
|
|
14
|
+
//
|
|
15
|
+
// A plugin can import github.com/microsoft/typescript-go/shim/ast while ttsc's
|
|
16
|
+
// driver imports the bridge or another facade. A facade type that were a new
|
|
17
|
+
// defined type would make a value from one path unusable through the other.
|
|
18
|
+
//
|
|
19
|
+
// 1. Load every committed facade module with its dependencies.
|
|
20
|
+
// 2. For every exported facade type that its bridge also exports, require an
|
|
21
|
+
// alias whose type is identical to the bridge's.
|
|
22
|
+
// 3. Spot-check the AST node, checker and Program identities by name.
|
|
23
|
+
//
|
|
24
|
+
// @evidence contracts/testing.md#behavioral-verification Type-checks the real facade and bridge modules through go/packages and asserts types.Identical for every exported pair, so a defined type, a wrong alias target or a missing alias fails.
|
|
25
|
+
// @evidence contracts/testing.md#independent-expectations The expected relation, one identical type per documented name, is the facade contract itself; the spot-checked names are written literally rather than read from generator output.
|
|
26
|
+
// @evidence contracts/testing.md#distinguishing-cases Covers every facade package, nested paths such as vfs/cachedvfs, generic and non-generic aliases, and the three named identities plugins and the driver exchange most.
|
|
27
|
+
// @evidence contracts/testing.md#execution-ownership This tools/gen_facade unit loads the committed modules through the go command in its own process and writes no file.
|
|
28
|
+
func TestFacadeTypesAreTheirBridgeTypes(t *testing.T) {
|
|
29
|
+
facadeRoot := filepath.Join("..", "..", "targets", "7.1", "facade")
|
|
30
|
+
var dirs []string
|
|
31
|
+
err := filepath.WalkDir(facadeRoot, func(path string, entry os.DirEntry, err error) error {
|
|
32
|
+
if err == nil && !entry.IsDir() && entry.Name() == "go.mod" {
|
|
33
|
+
dirs = append(dirs, filepath.Dir(path))
|
|
34
|
+
}
|
|
35
|
+
return err
|
|
36
|
+
})
|
|
37
|
+
if err != nil {
|
|
38
|
+
t.Fatal(err)
|
|
39
|
+
}
|
|
40
|
+
if len(dirs) == 0 {
|
|
41
|
+
t.Fatal("no facade modules found")
|
|
42
|
+
}
|
|
43
|
+
checked := map[string]bool{}
|
|
44
|
+
for _, dir := range dirs {
|
|
45
|
+
loaded, err := packages.Load(&packages.Config{
|
|
46
|
+
Dir: dir,
|
|
47
|
+
Env: standaloneModuleEnv(),
|
|
48
|
+
Mode: packages.NeedName | packages.NeedTypes | packages.NeedImports | packages.NeedDeps,
|
|
49
|
+
}, ".")
|
|
50
|
+
if err != nil || len(loaded) != 1 || len(loaded[0].Errors) > 0 {
|
|
51
|
+
t.Fatalf("load %s: %v %v", dir, err, loaded)
|
|
52
|
+
}
|
|
53
|
+
facade := loaded[0]
|
|
54
|
+
bridgePath := bridgePrefix + facade.PkgPath[len(facadePrefix):]
|
|
55
|
+
bridge := facade.Imports[bridgePath]
|
|
56
|
+
if bridge == nil {
|
|
57
|
+
t.Fatalf("%s does not import its bridge %s", facade.PkgPath, bridgePath)
|
|
58
|
+
}
|
|
59
|
+
for _, name := range facade.Types.Scope().Names() {
|
|
60
|
+
object, ok := facade.Types.Scope().Lookup(name).(*types.TypeName)
|
|
61
|
+
if !ok || !object.Exported() {
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
original, ok := bridge.Types.Scope().Lookup(name).(*types.TypeName)
|
|
65
|
+
if !ok {
|
|
66
|
+
continue
|
|
67
|
+
}
|
|
68
|
+
if !aliasesBridgeType(object, original) {
|
|
69
|
+
t.Errorf("%s.%s is not the bridge's %s", facade.PkgPath, name, original.Type())
|
|
70
|
+
}
|
|
71
|
+
checked[facade.PkgPath[len(facadePrefix):]+"."+name] = true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for _, name := range []string{"ast.Node", "ast.SourceFile", "ast.Symbol", "checker.Checker", "compiler.Program", "vfs/cachedvfs.FS"} {
|
|
75
|
+
if !checked[name] {
|
|
76
|
+
t.Errorf("identity of %s was not checked", name)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// aliasesBridgeType reports whether the facade type is an alias of original.
|
|
82
|
+
// A generic alias declares its own type parameters, so original is
|
|
83
|
+
// instantiated with them before the comparison.
|
|
84
|
+
func aliasesBridgeType(object *types.TypeName, original *types.TypeName) bool {
|
|
85
|
+
alias, ok := object.Type().(*types.Alias)
|
|
86
|
+
if !ok || !object.IsAlias() {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
params := alias.TypeParams()
|
|
90
|
+
if params.Len() == 0 {
|
|
91
|
+
return types.Identical(alias, original.Type())
|
|
92
|
+
}
|
|
93
|
+
args := make([]types.Type, params.Len())
|
|
94
|
+
for i := range params.Len() {
|
|
95
|
+
args[i] = params.At(i)
|
|
96
|
+
}
|
|
97
|
+
instance, err := types.Instantiate(nil, original.Type(), args, true)
|
|
98
|
+
return err == nil && types.Identical(alias.Rhs(), instance)
|
|
99
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
|
2
|
+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
3
|
+
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
|
4
|
+
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
|
5
|
+
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
|
6
|
+
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
|
7
|
+
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
|
8
|
+
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|