Skip to content

fix(ts-lsp): resolve JSX calls from top-level arrow components - #2579

Merged
DeusData merged 4 commits into
DeusData:mainfrom
lorenzozanee:fix/tsx-arrow-jsx-calls
Oct 20, 2026
Merged

DeusData merged 4 commits into
DeusData:mainfrom
lorenzozanee:fix/tsx-arrow-jsx-calls

Conversation

@lorenzozanee

Copy link
Copy Markdown
Contributor

What does this PR do?

Top-level const arrow components currently lose semantic CALLS edges to components rendered in JSX. This routes direct and export-wrapped arrow initializers through the existing TypeScript LSP body processor, preserving exact source-site resolution.

Validation: TMPDIR=/tmp scripts/test.sh --suites ts_lsp (311 passed) and TMPDIR=/tmp scripts/test.sh --suites extraction (434 passed). scripts/lint.sh did not complete because clang-tidy, cppcheck, and clang-format are unavailable.

AI disclosure: Prepared with OpenAI Codex on behalf of @lorenzozanee.

Fixes #2559

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test)
  • Lint passes (make -f Makefile.cbm lint-ci)
  • New behavior is covered by a test (reproduce-first for bug fixes)

Signed-off-by: lorenzozanee <wyz0707@proton.me>
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

@DeusData DeusData added bug Something isn't working parsing/quality Graph extraction bugs, false positives, missing edges labels Oct 19, 2026
@DeusData

Copy link
Copy Markdown
Owner

Thanks for addressing JSX calls from top-level arrow components and including both direct and exported forms. I have read the focused results and lint limitation; this remains pending maintainer review.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Walking top-level arrow components also bound every exported `const`
declaration into the module root scope in pass 1. A root-scope binding
makes the JSX resolver fail closed and the exact same-module call path
skip the name, so a same-file `<Badge />` rendered from a function
component lost its CALLS edge (JSX carriers have no other resolver), and
calls such as `formatLabel()` fell back from lsp_ts_local to same_module.

Walking the arrow bodies does not need that binding, so drop it, and pin
both forms with a test that renders and calls an exported arrow const
from a function component and from an arrow component.

On excalidraw/excalidraw @ e1b7aacb the change keeps every edge it adds
over main (+270 CALLS, 0 removed; 6 more same-file JSX edges than with
the binding) and the 17 lsp_ts_local -> same_module downgrades are gone.

Also joins one declaration line that clang-format reflows.

Refs DeusData#2559

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData

Copy link
Copy Markdown
Owner

Thank you very much for this, @lorenzozanee. Routing the top-level arrow initializers through the existing body processor is exactly the right layer: the calls keep their exact source sites, and your test pins the caller identity, the span and the strategy for direct, exported and declared components alike. We measured it on a real React code base (excalidraw) against current main: 160 new JSX render edges from arrow components, 104 new method calls resolved inside arrow functions, about 1,200 existing calls now confirmed by the TypeScript resolver, and nothing lost.

To get it merged without another round trip, we pushed a few small commits on top of your branch:

  1. Merged current main (twice, as it moved while we were testing). Both merges were clean.
  2. Dropped the extra export_statement branch in pass 1 of ts_lsp_process_file. Binding exported const declarations into the module scope makes the resolver treat them like lexical locals, so a same-file <Badge /> rendered from a function component lost its CALLS edge, and same-module calls such as formatLabel() fell back from lsp_ts_local to the weaker same_module strategy. Walking the arrow bodies does not need that binding. Without it, excalidraw keeps every edge your change adds, gains 6 more same-file JSX edges, and the 17 downgraded calls are back on lsp_ts_local.
  3. Added tslsp_jsx_exported_arrow_component_resolves_in_same_module, which renders and calls an exported arrow const from a function component and from an arrow component. It fails with the pass-1 binding and passes without it.
  4. Joined one wrapped declaration line in process_top_level_variable_arrows that clang-format reflows.

Other component shapes (memo/forwardRef wrappers, function expressions, export default arrows, class-property arrows) are outside what this PR claims, and we will follow up on them separately. Thanks again for a clean, well-tested fix.

@DeusData
DeusData merged commit fceb25d into DeusData:main Oct 20, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working parsing/quality Graph extraction bugs, false positives, missing edges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression since 0.10.0: JSX render edges dropped from arrow-function components (const X = () => <Child/>)

2 participants