Skip to content

fix(extract): parse TS 5 export type star re-exports (#3942) - #4303

Closed
ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-3942-ts-export-type-star
Closed

ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-3942-ts-export-type-star

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

Addresses the TypeScript half of #3942 (the Svelte half already shipped in v0.9.76 via #3984).

export type * from "./x" (TS 5.0's type-only star re-export) has no equivalent in tree-sitter-typescript 0.23 — currently the latest release on PyPI, confirmed by checking available versions. The grammar raises an ERROR node on the type keyword in this exact position, and the whole file is dropped, losing every symbol in it, not just the one statement. A barrel file that only re-exports types this way reported a syntax error and contributed nothing to the graph.

The construct is erased at compile time, the same as import type / export type { X } (both already handled correctly), so the graph only needs the re-export edge, not the type-only distinction. Added _normalize_ts_export_type_star, which blanks out just the type keyword — same byte length, same offsets — before parsing, so the grammar reads the ordinary, already-supported export * from "./x" form instead. Threaded into extract_js's existing TS source-normalization chain (alongside the existing import(...) type-argument workaround, composing cleanly with it since they target disjoint syntax).

Unlike that existing workaround, this prefix is never ambiguous with a runtime expression (export type * can only ever mean the type-only star re-export), so no AST-based disambiguation pass is needed — a direct regex match is sufficient and safe.

Verified against the issue's exact repro: before, index.ts reported a syntax error and extracted zero symbols; after, it correctly produces a re-export edge to types.ts, and types.ts's own FetchFn type survives. Confirmed the already-working named form (export type { X } from "./y") is untouched — still correctly stamped type_only for import-cycle exclusion (#1241/#3123). Four new regression tests in tests/test_ts_export_type_star.py, confirmed to fail against pre-fix code (import error, since the function didn't exist). Full suite passes clean — the only failures were the known editable-install-trap pattern (confirmed via a targeted rerun with correct module resolution: 110/110 pass) plus one pre-existing unrelated Erlang gap.

export type star from a module has no equivalent in tree sitter
typescript 0.23, the latest release: the grammar raises an error on
the type keyword in this position, and the whole file is dropped,
losing every symbol, not just the one statement. A barrel file that
only re exports types this way reported a syntax error and
contributed nothing to the graph.

The construct is erased at compile time, the same as import type and
export type with a brace list, so the graph only needs the re export
edge, not the type only distinction. Blank out the type keyword,
keeping every other byte and offset identical, before parsing, so the
grammar reads the ordinary, already supported star re export form
instead. Unlike the existing import call type argument workaround,
this prefix is never ambiguous with a runtime expression, so no AST
based disambiguation pass is needed here, only a direct text match.

Fixes Graphify-Labs#3942.
Covers the syntax error disappearing, the re export edge and the
target file's own symbol both surviving, the already working named
form staying untouched, and the normalize helper itself: it blanks
only the type keyword at the right byte offsets, and returns none
when there is no star form to rewrite. Confirmed to fail against pre
fix code with an import error, since the helper did not exist yet.
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @ayushcodes10. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 10, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).

Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Fixes TypeScript files containing export type * from "..." being dropped entirely: tree-sitter-typescript 0.23 errors on that type keyword. _normalize_ts_export_type_star now blanks the keyword in place, preserving byte offsets, so the file parses as a plain export * from and keeps its re-export edge and symbols. extract_js runs the existing import(...) type normalization on top of that rewrite; star re-exports lose their type-only distinction, while export type { X } keeps its type_only stamp.

Worth a look

  • Type-only star re-exports now emit runtime re-export edges without the type_only stamp — graphify/extract.py:2021 · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 2627 functions depend on the 293 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 844 callers, 51 callees
  • worse: extract_js() — 87 callers, 6 callees

Verification — 2627 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 2428 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

163 of 362 test file(s) selected (45%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_astro_import_ids.py — impact
  • tests/test_blade_extractor.py — impact
  • tests/test_build.py — impact
  • tests/test_builtin_global_type_refs.py — impact
  • tests/test_cache.py — impact
  • tests/test_case_sensitive_resolution.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cobol_extractor.py — impact
  • tests/test_cpp_method_declarations.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_cpp_objc_cross_file_calls.py — impact
  • tests/test_cross_extension_reexport_self_cycle.py — impact
  • tests/test_cross_language_call_resolution.py — impact
  • tests/test_cross_repo_external_call_guards.py — impact
  • tests/test_cross_repo_member_calls.py — impact
  • tests/test_csharp_call_site_generic_args.py — impact
  • tests/test_csharp_enum_members.py — impact
  • tests/test_csharp_field_generic_args.py — impact
  • tests/test_csharp_generic_callsites.py — impact
  • tests/test_csharp_interface_dispatch.py — impact
  • tests/test_csharp_member_calls.py — impact
  • tests/test_csharp_member_chain_calls.py — impact
  • tests/test_csharp_member_nodes.py — impact
  • tests/test_csharp_object_creation.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_csharp_tuple_type_refs.py — impact
  • tests/test_csharp_type_resolution.py — impact
  • tests/test_definition_file_portability.py — impact
  • tests/test_detect.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_duplicate_annotation_edges.py — impact
  • tests/test_elixir_import_resolution.py — impact
  • tests/test_elixir_keyword_def_calls.py — impact
  • tests/test_elixir_qualified_calls.py — impact
  • tests/test_elixir_unqualified_call_scope.py — impact
  • tests/test_erlang_extractor.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_cache_location.py — impact
  • tests/test_extract_path_memo.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_file_label_disambiguation.py — impact
  • tests/test_file_node_id_spec.py — impact
  • tests/test_forwarding_review_findings.py — impact
  • tests/test_go_builtin_call_targets.py — impact
  • tests/test_go_import_repoint.py — impact
  • tests/test_go_interface_methods.py — impact
  • tests/test_go_qualified_resolution.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_import_self_loops.py — impact
  • … and 113 more

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

No difference found (not proven): No behavior difference found in extract\_js (not a proof).

The verifier ran both versions of extract\_js on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

· 2 more finding(s) on lines outside this diff (see the check run).

safishamsi pushed a commit that referenced this pull request Oct 10, 2026
Landed from PR #4303 (squashed, authorship preserved).
@safishamsi

Copy link
Copy Markdown
Member

Landed in 0.9.85 (now on PyPI) via an authorship-preserving cherry-pick, so your commit authorship is retained. Thank you, @ayushcodes10!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants