| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Use the tsx tree-sitter grammar for .tsx files (the typescript grammar misparses JSX as type assertions). Override _find_calls() in TypescriptJSXTreeSitterParser to capture jsx_opening_element and jsx_self_closing_element nodes, filtering to PascalCase names only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve TS/JS import specifiers to absolute file paths during indexing so that Module nodes use resolved paths instead of raw specifiers. This makes File->Module->File traversal work correctly for relative and alias imports. - Create ts_import_resolver.py handling relative, alias (tsconfig paths), and bare specifier imports with extension/index file resolution - Fix lang routing bug: include 'typescript' and 'typescriptjsx' alongside 'javascript' in the import handling branch of graph_builder - Parse tsconfig.json once per indexing run (supports baseUrl, paths, extends, comments, trailing commas) - Store raw_specifier on Module nodes for debugging - Add test fixture files with tsconfig paths aliases (@utils/*, @models/*, @shared/*, @app/*) and corresponding source files - Add 50 unit + integration tests covering resolver, tsconfig parsing, and end-to-end resolution with real TS parser output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ts_import_resolver for resolving TypeScript path aliases from tsconfig.json - Track JSX component usage as CALLS relationships in graph builder - Add TSX test fixtures and e2e test for TypeScript indexing - Update sample TypeScript project with TSX components Amp-Thread-ID: https://ampcode.com/threads/T-019c6303-d1c9-763f-b9ab-08be8da73f8a Co-authored-by: Amp <amp@ampcode.com>
|
@alex4o is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
Sorry, something went wrong.
…icity - Resolve baseUrl-only imports (e.g. "utils/foo") before dismissing as bare specifiers - Replace naive regex comment stripping with state-aware parser to avoid corrupting strings containing "//" - Sort tsconfig path patterns by specificity (longest first) to match TypeScript behavior - Remove debug log from graph_builder.py - Improve E2E test assertions to parse JSON values instead of fragile string checks - Restore .cgcignore file Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
👋 Thanks for contributing to CodeGraphContext! Since this PR was opened, main has moved forward significantly (we just shipped v0.5.2 and merged ~50 PRs), so this one now has merge conflicts. Could you please rebase onto the latest main and resolve the conflicts? Once it is conflict-free and CI is green, we will review and merge it. Really appreciate your work — thank you! 🙏 |
Sorry, something went wrong.
|
Triage update: this tsconfig-paths resolver is still something we want — TS monorepos with path aliases currently lose those import edges. The branch has drifted a long way from main (the indexing pipeline was restructured into tools/indexing/), so it needs a rebase before it can be reviewed. @alex4o are you still interested in bringing it up to date? If not, we'll treat this as a design reference and reimplement against the current pipeline. Thanks for the substantial work either way! 🙏 |
Sorry, something went wrong.
|
Sry I don't have the time to contribute to this anymore |
Sorry, something went wrong.
|
I spent a solid session trying to land this and did not get it over the line. Recording everything so the effort is not lost — my working attempt is pushed to port/642-ts-import-resolver on this repo if you want to pick it up from there. This is a port, not a rebasemain has restructured underneath the PR. Two of your six conflict hunks in graph_builder.py target code that no longer exists:
So ts_config cannot be threaded the way the PR does it. The other four hunks are the old inline TreeSitterParser class, which moved to tools/tree_sitter_parser.py as a registry — and that registry already contains "tsx": TypescriptJSXTreeSitterParser, so the JSX half of this PR has effectively landed already via another route. What is definitely goodts_import_resolver.py is sound and lands cleanly. It applies to current main with no conflicts and its 35 unit tests pass unmodified: $ pytest tests/unit/parsers/test_ts_import_resolver.py -q
35 passedDriven directly it does exactly what it claims: @utils/string-helpers -> .../src/utils/string-helpers.ts SAME FILE ./utils/string-helpers -> .../src/utils/string-helpers.ts SAME FILE react -> unresolved (bare package, correct) What I could not finishI wired the resolver into GraphWriter.add_file_to_graph (cached per project root, so tsconfig is parsed once rather than per import). Confirmed by instrumenting a real add_file_to_graph call that it is invoked and does resolve. But end to end on the TS fixture: RESOLVED to a file path : 19
STILL an alias (failed) : 5 @models/user-model, @shared/constants,
@shared/logger, @utils/Button, @utils/string-helpers
bare package names (ok) : 2 react, reflect-metadata
Relative specifiers resolve; tsconfig aliases do not, even though the same aliases resolve when the resolver is called directly. My hypothesis was that tsconfig.json was being looked up from the indexed repo root rather than the TS project directory — I changed the lookup to walk up from the importing file, and the count did not move. So the cause is elsewhere and I have not found it. Partial resolution is arguably worse than none: it leaves Module names inconsistent, some file paths and some specifiers, which is a different kind of fragmentation from the one this PR set out to fix. That is why I have not merged it. One thing worth knowing, since it looks alarmingRegenerating the TS golden with your fixtures shows CALLS 389 → 262 and HEURISTIC_CALLS 0 → 141. I chased that specifically, because that exact signature is why I abandoned a different import fix in #1526. It is not caused by the resolver. I isolated it by regenerating with the fixtures present but the wiring removed — every edge count was identical: fixtures-only -> fixtures+resolver CALLS 262 -> 262 (+0) HEURISTIC_CALLS 141 -> 141 (+0) So the shift comes from the new fixture files themselves. Most likely they introduce same-named symbols across files, making previously-unambiguous calls ambiguous — which may be correct behaviour, but is worth a look, since it is a large swing for a fixture addition. Suggested path
Happy to review whenever you pick it up. |
Sorry, something went wrong.
|
Thanks for this, and sorry it's sat so long — the tsconfig path resolution is genuinely useful and ts_import_resolver.py (+247 lines, with 600 lines of tests) is well built. Unfortunately main has restructured the indexing pipeline underneath this branch since February, and the conflicts are no longer mechanical, so I can't resolve them for you without guessing at your intent. What changed on main:
The good news is that the actual substance of your PR — ts_import_resolver.py, the typescriptjsx.py changes, the fixtures and all the tests — merges cleanly. It's only the ts_config plumbing through the (now rewritten) indexing path that needs redoing. If you rebase onto current main and re-thread ts_config through writer.py's add_file_to_graph, I'll review and merge promptly. Happy to answer questions about the new pipeline shape if that helps — just reply here. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What
Index <JSXComponent /> tags as call-sites so component usage shows up in the code graph.
Resolve TS/TSX import paths (aliases from tsconfig.json and relative imports) to absolute file paths so two files importing the same module share one Module node instead of creating duplicates.
Why
Without this:
How
JSX call-site indexing
TS import resolution
Example
Testing