Skip to content

fix(tsconfig): scope default **/* include to the tsconfig directory#1161

Merged
Boshen merged 1 commit into
mainfrom
05-27-fix_tsconfig_scope_default_include_to_directory
May 27, 2026
Merged

fix(tsconfig): scope default **/* include to the tsconfig directory#1161
Boshen merged 1 commit into
mainfrom
05-27-fix_tsconfig_scope_default_include_to_directory

Conversation

@Boshen

@Boshen Boshen commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

The default include = **/* was matching every path regardless of where the tsconfig sat, so a referenced sub-project with no files/include of its own claimed files outside its own directory and shadowed the parent's compilerOptions.paths. Combined with the solution-style heuristic treating omitted files/include the same as explicit [], a root tsconfig with references and paths but no include lost its own paths for files it owns via the default glob.

Repro

repro/
├── tsconfig.json        compilerOptions: { paths: { "@app/*": ["./src/*"] } }, references: [{ path: "./pkg" }]
├── index.ts             import { util } from "@app/util";
├── src/util.ts
└── pkg/
    ├── tsconfig.json    compilerOptions: { composite: true }
    └── thing.ts

tsc 6.0.3 and tsgo 7.0.0-dev both resolve @app/utilsrc/util.ts. oxc-resolver 11.19.1 did too; 11.19.2 returns Cannot find module.

Root cause

Two interacting bugs:

  1. is_glob_matches(_, GlobPattern::All) short-circuited **/* to true regardless of which tsconfig owned the pattern. Fine when the only caller was the walked-up parent tsconfig, broken after fix(tsconfig): let project references take priority over their parent #1151 started asking references the same question — their **/* then matched files outside the reference's directory.
  2. claims_ownership_of's solution-style check used is_none_or(Vec::is_empty), conflating omitted and explicit-empty files/include. Per the TS spec only an explicit [] means "own no files"; an omitted include defaults to **/* and should fall through.

This mirrors typescript-go's structure: getFileNamesFromConfigSpecs expands the default **/* via ReadDirectory(basePath, ...), which is naturally scoped to the project directory — no equivalent "literal **/* matches everywhere" code path exists there.

Changes

  • src/tsconfig.rsGlobPattern::All now checks path.starts_with(self.directory()); is_solution_style requires explicit Some([]) for both files and include. Dead GLOB_ALL_PATTERN constant removed.
  • src/tests/tsconfig_project_references.rsroot_paths_apply_to_default_include_files covers the repro.
  • fixtures/tsconfig/cases/project-references-default-include/ — minimal fixture matching the issue.

All 294 existing tests still pass.

Closes #1159.

The default `include = **/*` was matching every path regardless of
where the tsconfig sat, so a referenced sub-project with no
`files`/`include` of its own claimed files outside its directory and
shadowed the parent's `compilerOptions.paths`. Combined with the
solution-style heuristic treating omitted `files`/`include` the same as
explicit `[]`, a root tsconfig with `references` and `paths` but no
`include` lost its own paths for files it owns via the default glob.

Mirrors typescript-go, where `getFileNamesFromConfigSpecs` expands the
default `**/*` via `ReadDirectory(basePath, ...)` and is therefore
naturally scoped to the project directory.

Closes #1159.
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.31%. Comparing base (53af0d7) to head (194d8c8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1161      +/-   ##
==========================================
- Coverage   93.34%   93.31%   -0.03%     
==========================================
  Files          22       22              
  Lines        4177     4174       -3     
==========================================
- Hits         3899     3895       -4     
- Misses        278      279       +1     

☔ 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

codspeed-hq Bot commented May 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing 05-27-fix_tsconfig_scope_default_include_to_directory (194d8c8) with main (c68ce07)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen force-pushed the 05-27-fix_tsconfig_scope_default_include_to_directory branch from af38e2f to 194d8c8 Compare May 27, 2026 04:28

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af38e2ff15

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/file_system.rs Outdated
@Boshen Boshen merged commit 827b45a into main May 27, 2026
32 checks passed
@Boshen Boshen deleted the 05-27-fix_tsconfig_scope_default_include_to_directory branch May 27, 2026 04:41
@oxc-guard oxc-guard Bot mentioned this pull request May 27, 2026
Boshen pushed a commit that referenced this pull request May 27, 2026
## 🤖 New release

* `oxc_resolver`: 11.19.2 -> 11.20.0
* `oxc_resolver_napi`: 11.19.2 -> 11.20.0

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[11.20.0](v11.19.2...v11.20.0)
- 2026-05-27

### <!-- 0 -->🚀 Features

- *(tsconfig)* parse `strict` and `strictNullChecks` compiler options
([#1166](#1166)) (by
@kylecannon)

### <!-- 1 -->🐛 Bug Fixes

- *(tsconfig)* scope default `**/*` include to the tsconfig directory
([#1161](#1161)) (by
@Boshen)

### Contributors

* @kylecannon
* @Boshen
</blockquote>



</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression (11.19.2): a root tsconfig with references drops its own paths for files matched by the default include (**/*)

1 participant