feat(parser): resolve TypeScript path aliases in IMPORTS_FROM edges#53
Closed
JF10R wants to merge 3 commits intotirth8205:mainfrom
Closed
feat(parser): resolve TypeScript path aliases in IMPORTS_FROM edges#53JF10R wants to merge 3 commits intotirth8205:mainfrom
JF10R wants to merge 3 commits intotirth8205:mainfrom
Conversation
…M edges Resolve TypeScript path aliases (e.g., @/ -> src/) by reading tsconfig.json compilerOptions.paths and baseUrl. Supports JSONC comments, recursive extends chains, and caches per repo root. IMPORTS_FROM edge targets are now resolved to absolute file paths when the target file exists on disk, enabling importers_of() queries to work with alias imports. New files: - tsconfig_resolver.py: TsconfigResolver class - test_tsconfig_resolver.py: 7 unit tests - fixtures for alias resolution testing
- _resolve_extends: garde positive au lieu du double-négatif - _match_pattern: early return + variable end explicite - tests: convertis en style pytest (cohérent avec le repo), test cache amélioré
There was a problem hiding this comment.
Pull request overview
Adds TypeScript tsconfig.json path-alias awareness to the graph parser so IMPORTS_FROM edges can resolve alias imports (e.g., @/…) to real on-disk files, enabling accurate importers_of() queries in TS/TSX/Vue projects.
Changes:
- Introduces
TsconfigResolverto discover/parsetsconfig.json(JSONC +extends) and resolvecompilerOptions.pathsaliases to existing files. - Integrates alias resolution into
CodeParsermodule resolution andIMPORTS_FROMedge extraction. - Adds unit/integration tests and fixtures to validate alias resolution and no-tsconfig behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
code_review_graph/tsconfig_resolver.py |
New resolver for tsconfig discovery, parsing, extends resolution, and alias-to-file probing. |
code_review_graph/parser.py |
Uses resolver during module resolution and updates IMPORTS_FROM edges to prefer resolved file paths. |
tests/test_tsconfig_resolver.py |
Unit tests for JSONC stripping, alias resolution, and caching behavior. |
tests/test_parser.py |
Integration tests ensuring alias imports resolve and missing tsconfig doesn’t break parsing. |
tests/fixtures/tsconfig.json |
Fixture tsconfig defining baseUrl and paths aliases used by tests. |
tests/fixtures/src/lib/utils.ts |
Fixture target file for alias resolution. |
tests/fixtures/alias_importer.ts |
Fixture importer using @/… alias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace regex-based JSONC comment stripping with a state-machine that skips comment markers inside quoted strings (fixes URL corruption) - Memoize all intermediate directories visited during tsconfig lookup to avoid O(depth) repeated walks - Sort path alias patterns by non-wildcard prefix length so more specific aliases win regardless of JSON insertion order - Fix _probe_path: append extension instead of replacing existing suffix - Align _resolve_extends docstring: "Shallow-merges" (dict.update) - tests/test_parser.py: split `import tempfile, os`, use TemporaryDirectory for isolation, fix E501 long assert lines - tests/test_tsconfig_resolver.py: replace hard-coded /tmp path with tempfile.TemporaryDirectory Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
All 9 review comments addressed in 9093057: tsconfig_resolver.py:
Tests:
|
tirth8205
added a commit
that referenced
this pull request
Mar 26, 2026
Adds TsconfigResolver module that resolves TypeScript path aliases (e.g., @/ -> src/) from tsconfig.json compilerOptions.paths. Also resolves import targets to absolute file paths in IMPORTS_FROM edges. Co-Authored-By: JF10R <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
tirth8205
added a commit
that referenced
this pull request
Mar 26, 2026
…nfigurable embeddings, MiniMax, Perl) * feat: integrate PR #43 — R language support Adds R language parsing with function extraction (both <- and = assignment), S4/R5 class detection via setClass/setRefClass, library/require/source imports, namespace-qualified calls (dplyr::filter), and testthat test detection. Co-Authored-By: michael-denyer <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #54 — Vitest/Jest test detection Adds describe/it/test block parsing for JS/TS test files, producing synthetic Test nodes with description labels. Supports modifier suffixes (describe.only, it.skip, test.each) and nested describe/it containment. Co-Authored-By: JF10R <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #53 — tsconfig path alias resolution Adds TsconfigResolver module that resolves TypeScript path aliases (e.g., @/ -> src/) from tsconfig.json compilerOptions.paths. Also resolves import targets to absolute file paths in IMPORTS_FROM edges. Co-Authored-By: JF10R <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #58 — .mjs/.astro support Adds .mjs extension mapping to JavaScript and .astro extension mapping to TypeScript for import path resolution. Co-Authored-By: zoneghost7 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #55 — configurable embedding model Adds CRG_EMBEDDING_MODEL env var and model parameter to embedding functions, allowing users to specify any sentence-transformers compatible model. Changing the model re-embeds all nodes automatically. Co-Authored-By: eugenepro2 <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #45 — MiniMax embedding provider Adds MiniMaxEmbeddingProvider using the embo-01 model (1536 dimensions) with support for distinct task types (db/query), batching, and retry logic. Co-Authored-By: octo-patch <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: integrate PR #62 — Perl support Adds Perl language parsing with package detection, subroutine extraction, use/require imports, and function call tracking. Includes test fixture and comprehensive test class. Co-Authored-By: potatogim <noreply@github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: michael-denyer <noreply@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Integrated into main via PR #68. Thank you for the contribution! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TsconfigResolverclass that discovers and parsestsconfig.jsonfiles (with JSONC comment support and recursiveextendsresolution)@/*→src/*) declared incompilerOptions.pathsto absolute file pathsimporters_of()queries to work with alias importsBefore:
importers_of('src/hooks/useApiData.ts')returned 0 results despite 28 files importing it via@/hooks/useApiDataAfter: Returns all 28 importers correctly
Changes
code_review_graph/tsconfig_resolver.py—TsconfigResolverclass with tsconfig discovery, JSONC parsing,extendschain resolution, path alias matching, and filesystem probingcode_review_graph/parser.py— integrated resolver into_do_resolve_module()for non-relative imports and_extract_from_tree()for IMPORTS_FROM edge resolutiontests/test_tsconfig_resolver.py(7 unit tests) + 2 integration tests intest_parser.pytsconfig.json,src/lib/utils.ts,alias_importer.tsDesign decisions
extendschains with cycle detection; skips npm-scoped extends (e.g.,@tsconfig/recommended)Test plan
pytest tests/test_parser.py tests/test_tsconfig_resolver.py -v)importers_of()returns correct results for alias-imported files🤖 Generated with Claude Code