Skip to content

fix: support extends in referenced project#142

Merged
JounQin merged 2 commits intomainfrom
fix/extends_references
Jun 10, 2025
Merged

fix: support extends in referenced project#142
JounQin merged 2 commits intomainfrom
fix/extends_references

Conversation

@JounQin
Copy link
Member

@JounQin JounQin commented Jun 9, 2025

fix import-js/eslint-import-resolver-typescript#400
close #138


Important

Refactor TypeScript configuration extension logic and add tests to support module path resolution with project references and configuration inheritance.

  • Behavior:
    • Refactor extend_tsconfig logic in lib.rs to handle TypeScript configuration extensions in referenced projects.
    • Add extend_tsconfig function to encapsulate extension logic in lib.rs.
  • Tests:
    • Add references_with_extends test in tsconfig_project_references.rs to verify module path resolution with TypeScript project references and configuration inheritance.
  • Configuration:
    • Add tsconfig.app.json and tsconfig.base.json to demonstrate configuration inheritance in fixtures/tsconfig/cases/project_references/extends.

This description was created by Ellipsis for b2878f6. You can customize this summary. It will automatically update as commits are pushed.


Summary by CodeRabbit

  • New Features
    • Introduced a new React component named Home.
    • Added new TypeScript configuration files to support project references and JSX handling.
  • Tests
    • Added a test to verify correct resolution of aliased paths with project references and extended tsconfig files.
  • Refactor
    • Improved internal handling of TypeScript configuration extension logic for better maintainability.

@JounQin JounQin requested a review from Copilot June 9, 2025 16:45
@JounQin JounQin self-assigned this Jun 9, 2025
@JounQin JounQin added the bug Something isn't working label Jun 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 9, 2025

Walkthrough

This change refactors the logic for handling TypeScript configuration inheritance and project references. It introduces new helper methods to ensure that referenced tsconfig files properly resolve their own extends clauses. New test cases and fixture files demonstrate and verify the correct resolution of aliased paths when using both references and extends in tsconfig setups.

Changes

File(s) Change Summary
fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json,
tsconfig.app.json,
tsconfig.json
Added new TypeScript config files to test project references and config extension.
fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx Added a new React Home component as a test target for path resolution.
src/lib.rs Refactored tsconfig loading logic: extracted extension logic to extend_tsconfig and applied it to referenced configs.
src/tests/tsconfig_project_references.rs Added test references_with_extends to verify correct resolution for extended referenced configs.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Runner
    participant Resolver as ResolverGeneric
    participant Tsconfig as Tsconfig Loader

    Test->>Resolver: initialize with tsconfig.json (with references)
    Resolver->>Tsconfig: load tsconfig.json
    Tsconfig->>Tsconfig: for each reference, load referenced tsconfig (e.g., tsconfig.app.json)
    Tsconfig->>Tsconfig: for each referenced tsconfig, resolve "extends" (e.g., tsconfig.base.json)
    Tsconfig->>Tsconfig: merge extended configs into referenced config
    Resolver->>Test: resolve aliased path (e.g., "@/pages") using merged config
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure referenced tsconfig files correctly resolve and apply their own "extends" clauses (#400, #138)
Refactor and encapsulate tsconfig extension logic in dedicated function (#138)
Add tests and fixtures demonstrating resolution with references and extends (#400, #138)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.

Poem

In the warren where configs nest and grow,
Now references extend, as they’re meant to flow.
Paths resolve with glee, thanks to helpers new,
Each tsconfig finds its kin, and tests hop through.
🐇✨
Code is tidy, logic clear—
The resolver’s future’s bright this year!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acccae1 and b2878f6.

📒 Files selected for processing (5)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.app.json (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.json (1 hunks)
  • src/lib.rs (3 hunks)
  • src/tests/tsconfig_project_references.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: JounQin
PR: unrs/unrs-resolver#72
File: fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json:4-6
Timestamp: 2025-04-20T16:00:16.106Z
Learning: The configuration with `".": ["."]` in the paths setting in fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json is an intentional test case for testing the TypeScript dot alias resolution behavior, specifically related to issue #437 in the eslint-import-resolver-typescript repository.
fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json (1)
Learnt from: JounQin
PR: unrs/unrs-resolver#72
File: fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json:4-6
Timestamp: 2025-04-20T16:00:16.106Z
Learning: The configuration with `".": ["."]` in the paths setting in fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json is an intentional test case for testing the TypeScript dot alias resolution behavior, specifically related to issue #437 in the eslint-import-resolver-typescript repository.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
src/lib.rs (3)

332-332: LGTM: Good refactoring to extract extension logic.

The call to extend_tsconfig ensures that the main tsconfig properly handles extensions before processing references.


348-351: LGTM: Consistent extension handling for referenced tsconfigs.

The refactoring ensures that referenced tsconfigs also go through the extension process, which is essential for supporting extends in project references.


362-376: LGTM: Well-structured extraction of extension logic.

The new extend_tsconfig method properly:

  • Collects all extended tsconfig paths
  • Loads each extended tsconfig recursively
  • Merges configurations via tsconfig.extend_tsconfig()
  • Handles errors appropriately

This encapsulation improves code reusability and maintainability.

fixtures/tsconfig/cases/project_references/extends/tsconfig.app.json (1)

1-3: LGTM: Clean fixture setup for testing extends functionality.

The configuration correctly extends the base tsconfig, establishing the inheritance chain needed for the test scenario.

fixtures/tsconfig/cases/project_references/extends/tsconfig.json (1)

1-8: LGTM: Proper project reference setup for testing.

The configuration correctly establishes a project reference to tsconfig.app.json, creating the chain needed to test extends functionality within project references.

fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json (1)

1-9: LGTM: Well-structured base configuration with path aliases.

The configuration properly defines JSX transformation and path aliases using the ${configDir} template variable. The path alias @/* mapping to src/* is correctly structured for the test scenario.

Based on previous learnings, similar path configurations in fixture files are intentional test cases for alias resolution behavior.

src/tests/tsconfig_project_references.rs (1)

226-242:

Details

❓ Verification inconclusive

Verify that extends functionality properly merges path aliases in referenced projects.

The test implementation looks correct, but based on past review comments, it's failing with Err(NotFound("@/pages")). This suggests that path aliases from tsconfig.base.json aren't being properly merged through the extends chain in project references.

Run the following script to verify the test failure and debug the extends resolution:

If the test continues to fail, the issue likely lies in how tsconfig.extend_tsconfig() merges compiler options, particularly the paths field, when processing referenced configurations.


🏁 Script executed:

#!/bin/bash
# Description: Debug the extends resolution in project references test

# Run the specific failing test to see current behavior
cargo test references_with_extends -- --nocapture

# Verify the source file exists
echo "Checking if target source file exists:"
ls -la "fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx"

# Test basic tsconfig loading without references to isolate the issue
echo "Testing if the path alias works without project references:"
cargo test -p oxc_resolver -- --nocapture extends 2>&1 | grep -A 5 -B 5 "NotFound"

Length of output: 5245


Unable to reproduce test failure – manual verification required

The test run aborted due to a missing C linker (cc), so we can’t confirm whether the extends/path-alias merge is broken. Please:

  • Ensure a C compiler is installed (so cargo test references_with_extends can complete).
  • Rerun the specific test in src/tests/tsconfig_project_references.rs (lines 226–242) and confirm whether it still errors with Err(NotFound("@/pages")).
  • Verify that the fixture exists at fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx (it’s present but zero-length currently).

Once you’ve confirmed the test outcome, we can determine if the extend-merging logic needs fixing.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This comment was marked as outdated.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to cf6de51 in 1 minute and 33 seconds. Click for details.
  • Reviewed 63 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 7 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. fixtures/tsconfig/cases/project_references/extends/src/app.tsx:1
  • Draft comment:
    Re-exporting 'Home' from '@/pages'; ensure alias resolution works via the extended tsconfig.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx:1
  • Draft comment:
    Minimal export of Home component; consider adding an explicit return type if clarity is needed.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. fixtures/tsconfig/cases/project_references/extends/tsconfig.app.json:1
  • Draft comment:
    Good usage of the 'extends' field to inherit settings from tsconfig.base.json.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json:2
  • Draft comment:
    Configuration includes a paths alias with '${configDir}'; ensure the variable substitution is correctly supported. Trailing commas are acceptable in JSONC.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. src/tests/tsconfig_project_references.rs:227
  • Draft comment:
    The 'references_with_extends' test validates that extended tsconfig files are processed correctly and that alias resolution ('@/pages') resolves to the proper file.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
6. fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json:6
  • Draft comment:
    Trailing comma detected after the closing brace of the 'paths' object. In standard JSON, trailing commas are not allowed. Consider removing it.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% While it's true that standard JSON doesn't allow trailing commas, tsconfig.json files specifically DO allow trailing commas. This is a well-known TypeScript feature to make the config files more maintainable. The comment is technically incorrect because it's applying standard JSON rules to a TypeScript-specific file format. Maybe there's a specific reason they want to enforce strict JSON format across all config files for consistency? No, tsconfig.json files are specifically designed to support trailing commas, and enforcing standard JSON format would actually go against TypeScript's intended usage. Delete this comment because it's incorrect - trailing commas are explicitly allowed in tsconfig.json files.
7. fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json:7
  • Draft comment:
    Trailing comma detected after the closing brace of the 'compilerOptions' object. In standard JSON, trailing commas are not allowed. Please remove it to ensure proper JSON parsing.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The comment is technically correct - there is a trailing comma after the paths object. However, this is a tsconfig.json file, which follows a more lenient JSON5-like format that actually allows trailing commas. TypeScript configuration files commonly use trailing commas and it's considered good practice. The comment is suggesting fixing something that isn't actually a problem. Maybe there's a specific reason they want strict JSON compliance here? Maybe this file needs to be parsed by a tool that only accepts standard JSON? No, this is clearly a TypeScript config file meant for TypeScript consumption, and TypeScript explicitly supports trailing commas in these files. The comment is applying standard JSON rules where they don't apply. The comment should be deleted because it's suggesting to fix something that isn't actually a problem - trailing commas are valid and common in tsconfig files.

Workflow ID: wflow_YFDM1swxVGEW7i3A

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acccae1 and cf6de51.

📒 Files selected for processing (6)
  • fixtures/tsconfig/cases/project_references/extends/src/app.tsx (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.app.json (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json (1 hunks)
  • fixtures/tsconfig/cases/project_references/extends/tsconfig.json (1 hunks)
  • src/tests/tsconfig_project_references.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: JounQin
PR: unrs/unrs-resolver#72
File: fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json:4-6
Timestamp: 2025-04-20T16:00:16.106Z
Learning: The configuration with `".": ["."]` in the paths setting in fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json is an intentional test case for testing the TypeScript dot alias resolution behavior, specifically related to issue #437 in the eslint-import-resolver-typescript repository.
fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json (1)
Learnt from: JounQin
PR: unrs/unrs-resolver#72
File: fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json:4-6
Timestamp: 2025-04-20T16:00:16.106Z
Learning: The configuration with `".": ["."]` in the paths setting in fixtures/tsconfig/cases/dot-alias/tsconfigs/tsconfig.base.json is an intentional test case for testing the TypeScript dot alias resolution behavior, specifically related to issue #437 in the eslint-import-resolver-typescript repository.
🧬 Code Graph Analysis (1)
src/tests/tsconfig_project_references.rs (5)
src/tests/mod.rs (1)
  • fixture_root (32-34)
src/tests/tsconfig_paths.rs (2)
  • resolver (392-416)
  • default (364-388)
src/lib.rs (2)
  • new (152-159)
  • default (145-147)
napi/index.d.ts (1)
  • TsconfigOptions (212-227)
src/options.rs (1)
  • default (476-502)
🪛 GitHub Check: Codacy Static Code Analysis
fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx

[warning] 1-1: fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx#L1
Unexpected empty arrow function.

fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json

[failure] 7-7: fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json#L7
Unexpected character ('}' (code 125)): was expecting double-quote to start field name

🪛 Biome (1.9.4)
fixtures/tsconfig/cases/project_references/extends/tsconfig.base.json

[error] 7-7: Expected a property but instead found '}'.

Expected a property here.

(parse)

🪛 GitHub Actions: Code Coverage
src/tests/tsconfig_project_references.rs

[error] 240-240: Test failure in 'tests::tsconfig_project_references::references_with_extends': assertion left == right failed. Expected Ok path but got Err(NotFound("@/pages")).

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test (windows-latest)
🔇 Additional comments (4)
fixtures/tsconfig/cases/project_references/extends/tsconfig.app.json (1)

1-3: LGTM! Clean configuration extension.

The configuration correctly extends the base config, which is exactly what's needed for testing the extends functionality in project references.

fixtures/tsconfig/cases/project_references/extends/src/app.tsx (1)

1-1: LGTM! Perfect test case for path alias resolution.

This re-export demonstrates the path alias functionality that needs to work correctly with project references and extends. The syntax is clean and serves the test purpose well.

fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx (1)

1-1: LGTM! Appropriate test fixture implementation.

The empty arrow function is intentional for this test fixture. The component serves its purpose of testing module resolution and path aliasing without needing a complex implementation.

🧰 Tools
🪛 GitHub Check: Codacy Static Code Analysis

[warning] 1-1: fixtures/tsconfig/cases/project_references/extends/src/pages/index.tsx#L1
Unexpected empty arrow function.

fixtures/tsconfig/cases/project_references/extends/tsconfig.json (1)

1-6: LGTM! Standard project references configuration.

The configuration correctly sets up a TypeScript project references structure with an empty files array and a reference to tsconfig.app.json. This follows standard patterns for composite TypeScript projects.

@codecov
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.41%. Comparing base (acccae1) to head (b2878f6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
+ Coverage   93.40%   93.41%   +0.01%     
==========================================
  Files          13       13              
  Lines        2894     2902       +8     
==========================================
+ Hits         2703     2711       +8     
  Misses        191      191              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 10, 2025

CodSpeed Performance Report

Merging #142 will not alter performance

Comparing fix/extends_references (b2878f6) with main (acccae1)

Summary

✅ 3 untouched benchmarks

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 19d1aec in 2 minutes and 16 seconds. Click for details.
  • Reviewed 122 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/lib.rs:1362
  • Draft comment:
    In the new extend_tsconfig function, consider adding inline documentation about its recursive merge logic and how it handles circular references. Although self‐reference is checked later, additional comments would improve maintainability.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% While documentation could be helpful, the comment is vague and makes assumptions about the implementation. The code appears to handle basic extension but may not actually have recursive merge or circular reference handling. The comment asks for documentation of functionality that may not exist. The function's behavior seems straightforward from the code. I could be wrong about the circular reference handling - there may be protections against that elsewhere in the codebase that I can't see. The merge logic may also be more complex than it appears. Even if there is additional complexity elsewhere, this comment is still too vague and speculative to be actionable. It makes assumptions about the implementation without evidence. Delete this comment. While documentation could be valuable, this comment makes assumptions about the implementation and is not specific enough about what documentation is actually needed.
2. src/lib.rs:1402
  • Draft comment:
    In get_extended_tsconfig_path, consider using specifier.chars().next() instead of as_bytes().first() for clarity and better Unicode support, even if most tsconfig extends are ASCII.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. src/tests/tsconfig_project_references.rs:9
  • Draft comment:
    Minor typo: change "defined it's own paths alias" to "defined its own paths alias" in the comment.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_kOBiQaaHptObnUOf

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/fs_cache.rs (1)

198-202: Implementation looks correct with minor code duplication.

The build method implementation is correct and follows the expected caching pattern. There's some duplication with the get_tsconfig method (lines 193-194), but the separation of concerns is reasonable - build handles pre-processed tsconfigs while get_tsconfig handles the full load-and-process workflow.

src/lib.rs (1)

362-376: Consider adding circular dependency detection for extends chains.

The recursive extend_tsconfig method correctly implements the extends functionality, but it relies on the existing caching mechanism to prevent infinite loops from circular extends. While this may work in practice, explicit circular dependency detection would make the code more robust.

Consider tracking the extends chain to detect circular dependencies:

-fn extend_tsconfig(&self, directory: &C::Cp, tsconfig: &mut C::Tc) -> Result<(), ResolveError> {
+fn extend_tsconfig(&self, directory: &C::Cp, tsconfig: &mut C::Tc) -> Result<(), ResolveError> {
+    self.extend_tsconfig_with_chain(directory, tsconfig, &mut FxHashSet::default())
+}
+
+fn extend_tsconfig_with_chain(&self, directory: &C::Cp, tsconfig: &mut C::Tc, chain: &mut FxHashSet<PathBuf>) -> Result<(), ResolveError> {
+    let current_path = tsconfig.path().to_path_buf();
+    if !chain.insert(current_path.clone()) {
+        return Err(ResolveError::TsconfigCircularExtends(current_path));
+    }
     let extended_tsconfig_paths = tsconfig
         .extends()
         .map(|specifier| self.get_extended_tsconfig_path(directory, tsconfig, specifier))
         .collect::<Result<Vec<_>, _>>()?;
     for extended_tsconfig_path in extended_tsconfig_paths {
         let extended_tsconfig = self.load_tsconfig(
             /* root */ false,
             &extended_tsconfig_path,
             &TsconfigReferences::Disabled,
         )?;
         tsconfig.extend_tsconfig(&extended_tsconfig);
     }
+    chain.remove(&current_path);
     Ok(())
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf6de51 and 19d1aec.

📒 Files selected for processing (4)
  • src/cache.rs (1 hunks)
  • src/fs_cache.rs (1 hunks)
  • src/lib.rs (2 hunks)
  • src/tests/tsconfig_project_references.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/tsconfig_project_references.rs
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/cache.rs (2)
src/fs_cache.rs (2)
  • build (198-202)
  • path (325-327)
src/tsconfig.rs (4)
  • build (150-187)
  • path (34-34)
  • path (369-369)
  • tsconfig (373-373)
src/lib.rs (1)
src/tsconfig.rs (5)
  • directory (42-42)
  • tsconfig (373-373)
  • path (34-34)
  • path (369-369)
  • extend_tsconfig (81-142)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Upload coverage file
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Benchmark
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/cache.rs (1)

56-56: LGTM! Clean trait extension for tsconfig caching.

The new build method provides a clean interface for caching finalized tsconfig instances, which supports the enhanced tsconfig extension workflow introduced in this PR.

src/lib.rs (2)

332-332: Good addition of tsconfig extension support.

The call to extend_tsconfig properly ensures that the root tsconfig is extended before processing references.


339-356: Well-structured handling of referenced tsconfigs with extends support.

The variable renaming to tsconfig_arc improves clarity, and the addition of extend_tsconfig calls for referenced tsconfigs achieves the PR objective of supporting extends in project references.

@JounQin JounQin force-pushed the fix/extends_references branch 2 times, most recently from bd7dabe to abc8962 Compare June 10, 2025 07:12
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed bd7dabe in 1 minute and 11 seconds. Click for details.
  • Reviewed 92 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/tsconfig_project_references.rs:9
  • Draft comment:
    Minor typo in the comment – consider replacing "it's own paths alias" with "its own paths alias" for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. src/tests/tsconfig_project_references.rs:79
  • Draft comment:
    Tests cover various scenarios (auto, disabled, manual, self-reference, and references with extends) very well. To reduce repetition in test blocks, consider extracting common setup patterns (e.g. fixture root and resolver creation) into helper functions if the suite grows further.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_7FOkdbYsoN25Q5bf

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed abc8962 in 1 minute and 7 seconds. Click for details.
  • Reviewed 80 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/lib.rs:1362
  • Draft comment:
    The new 'extend_tsconfig' function cleanly extracts the logic for merging extended tsconfigs. Consider adding an inline comment explaining that passing TsconfigReferences::Disabled to load extended configs is intentional to avoid processing their references.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50% None
2. src/tests/tsconfig_project_references.rs:216
  • Draft comment:
    The test 'self_reference' effectively checks for self-reference errors. Ensure that the path comparison (e.g. f.join("app/tsconfig.json")) remains robust across different platforms (e.g. Windows vs Unix) by using normalized paths if needed.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50% None
3. src/tests/tsconfig_project_references.rs:227
  • Draft comment:
    The newly added 'references_with_extends' test case is comprehensive and verifies that tsconfigs extending other configs are merged correctly. No issues found here.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_kz9sdg4FCmeesIr0

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@JounQin JounQin force-pushed the fix/extends_references branch from abc8962 to 1f37c39 Compare June 10, 2025 07:17
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 1f37c39 in 50 seconds. Click for details.
  • Reviewed 93 lines of code in 3 files
  • Skipped 1 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/tsconfig_project_references.rs:225
  • Draft comment:
    The new 'references_with_extends' test effectively verifies that tsconfig 'extends' in referenced projects is processed correctly. The expected resolution (to 'src/pages/index.tsx') appears correct.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. src/tests/tsconfig_project_references.rs:195
  • Draft comment:
    The 'self_reference' tests properly check that cyclic tsconfig references trigger a TsconfigSelfReference error. The varied config_file inputs ensure robustness.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. src/tests/tsconfig_project_references.rs:28
  • Draft comment:
    The use of #[rustfmt::skip] on the test arrays is acceptable to maintain the intended formatting; consider adding brief inline comments if more context is needed for each test case variant.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_PNC3ypMd7pN2SJLk

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@JounQin JounQin force-pushed the fix/extends_references branch from 1f37c39 to b2878f6 Compare June 10, 2025 07:22
@sonarqubecloud
Copy link

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed b2878f6 in 49 seconds. Click for details.
  • Reviewed 104 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/tests/tsconfig_project_references.rs:29
  • Draft comment:
    The 'auto' test cases thoroughly cover different alias and reference scenarios. Adding a brief inline note summarizing each expected behavior (e.g. project reference vs paths alias fallbacks) could improve future readability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
2. src/tests/tsconfig_project_references.rs:118
  • Draft comment:
    Direct comparison of error values (e.g. NotFound("@/index.ts")) might be brittle if error details change. Consider using pattern matching or error type identifiers for robust assertions.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. src/tests/tsconfig_project_references.rs:200
  • Draft comment:
    The self_reference tests correctly trigger TsconfigSelfReference errors. Consider also testing nested self-references (if applicable) to further validate the prevention of circular tsconfig extends.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. src/tests/tsconfig_project_references.rs:226
  • Draft comment:
    The new 'references_with_extends' test effectively verifies that extended tsconfig configurations are processed as expected. It might be beneficial to add further cases (e.g., multiple levels of extends) to cover more edge scenarios.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_sJ68JoH0ChJ5ioC0

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@JounQin JounQin requested a review from Copilot June 10, 2025 07:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for resolving TypeScript extends in projects using configuration inheritance and references.

  • Refactors tsconfig extension logic into a dedicated helper (extend_tsconfig) in lib.rs
  • Integrates extension handling when loading referenced tsconfig files
  • Adds a new test (references_with_extends) and fixture configs to validate extends behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

File Description
src/lib.rs Extracted existing inline extends logic into extend_tsconfig and invoked it for root and references
src/tests/tsconfig_project_references.rs Introduced references_with_extends test to verify resolution of module paths with extends
fixtures/tsconfig/cases/project_references/extends/tsconfig.* Added tsconfig.json, tsconfig.base.json, and tsconfig.app.json to simulate inheritance chain
Comments suppressed due to low confidence (3)

src/lib.rs:1362

  • Add a doc comment explaining the purpose, inputs, and behavior of extend_tsconfig to improve maintainability and ease of understanding for future readers.
fn extend_tsconfig(&self, directory: &C::Cp, tsconfig: &mut C::Tc) -> Result<(), ResolveError> {

src/lib.rs:1362

  • [nitpick] The helper is named the same as the Tsconfig::extend_tsconfig method. Consider renaming it (e.g., apply_extends or merge_extended_configs) to reduce confusion between the helper and the object method.
fn extend_tsconfig(&self, directory: &C::Cp, tsconfig: &mut C::Tc) -> Result<(), ResolveError> {

src/tests/tsconfig_project_references.rs:226

  • Consider adding tests for deeper or multi-level extends chains (beyond two levels) and conflicting overrides to ensure recursive merging behaves correctly in all scenarios.
#[test]

@JounQin
Copy link
Member Author

JounQin commented Jun 10, 2025

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Jun 10, 2025

✅ Actions performed

Full review triggered.

@JounQin JounQin merged commit 98a895c into main Jun 10, 2025
22 checks passed
@JounQin JounQin deleted the fix/extends_references branch June 10, 2025 08:15
@JounQin JounQin mentioned this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import/no-unresolved if tsconfig from references is extended

2 participants