Skip to content

feat(tsconfig): auto-exclude outDir and declarationDir from include walk - #1165

Closed
Boshen wants to merge 1 commit into
05-27-feat_tsconfig_transitive_project_referencesfrom
05-27-feat_tsconfig_default_exclude_outdir
Closed

Boshen wants to merge 1 commit into
05-27-feat_tsconfig_transitive_project_referencesfrom
05-27-feat_tsconfig_default_exclude_outdir

Conversation

@Boshen

@Boshen Boshen commented May 27, 2026

Copy link
Copy Markdown
Member

Stacked on #1164 (which is stacked on #1162). Diff to review is the single commit on top.

Summary

Port typescript-go's behavior at internal/tsoptions/tsconfigparsing.go:1240-1252: when the user specifies no exclude, the include walk implicitly skips outDir and declarationDir. Without this, a project's compiled .d.ts outputs would be re-included in its own program — silently doubling files and giving the wrong tsconfig in ownership queries.

Changes

  • New out_dir / declaration_dir fields on CompilerOptions, normalized at parse time (same pattern as root_dirs) so they survive extends into a different directory. ${configDir} template substitution still happens in build().
  • populate_owned_files skips recursing into those directories when exclude is None.
  • path_matches_specs (the virtual-path fallback added in refactor(tsconfig): precompute owned-file sets via directory walk #1162) applies the same exclusion, so behavior is consistent for paths that don't exist on disk.
  • New implicit_output_excludes helper centralizes the "no user exclude → use outDir / declarationDir" decision.

Test

project-outdir-exclude/: nested config with outDir: ./dist. Querying inner/dist/foo.d.ts now falls past the inner config (which auto-excludes its own dist) and is owned by the outer config — matching typescript-go's project-discovery behavior.

Port typescript-go's behavior at
`internal/tsoptions/tsconfigparsing.go:1240-1252`: when the user
specifies no `exclude`, the include walk implicitly skips `outDir` and
`declarationDir`. Without this, a project's compiled `.d.ts` outputs
would be re-included in its own program — silently doubling files and
giving the wrong tsconfig in ownership queries.

- New `out_dir` / `declaration_dir` fields on `CompilerOptions`,
  normalized at parse time (same pattern as `root_dirs`) so they
  survive `extends` into a different directory, with ${configDir}
  template substitution still happening in `build()`.
- `populate_owned_files` skips recursing into those directories when
  `exclude` is `None`.
- `path_matches_specs` (the virtual-path fallback) applies the same
  exclusion, so behavior is consistent for paths that don't exist on
  disk yet.
- `implicit_output_excludes` helper centralizes the "no user exclude →
  use outDir/declarationDir" decision.
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.76923% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.18%. Comparing base (a18b497) to head (9d223c8).

Files with missing lines Patch % Lines
src/tsconfig.rs 80.76% 10 Missing ⚠️
Additional details and impacted files
@@                                  Coverage Diff                                  @@
##           05-27-feat_tsconfig_transitive_project_references    #1165      +/-   ##
=====================================================================================
- Coverage                                              93.31%   93.18%   -0.14%     
=====================================================================================
  Files                                                     22       22              
  Lines                                                   4265     4315      +50     
=====================================================================================
+ Hits                                                    3980     4021      +41     
- Misses                                                   285      294       +9     

☔ 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.

@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: 9d223c817d

ℹ️ 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/tsconfig.rs
if entry.file_type.is_dir() {
if !is_default_excluded_dir(&entry.path) {
if !is_default_excluded_dir(&entry.path)
&& !implicit_output_excludes.iter().any(|d| entry.path == *d)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize output excludes before comparing walked entries

When a tsconfig is reached through a symlinked directory, parse stores outDir/declarationDir relative to the canonical config path, but populate_owned_files walks from the preserved caller-supplied self.directory() and read_dir returns entries under that symlink path. In that context this exact equality never matches, so the output directory is still recursed into and its files are claimed by the project; the same path-space mismatch also affects the virtual-path fallback. Compare against the walked/caller path, or canonicalize both sides, before deciding to push the directory.

Useful? React with 👍 / 👎.

@codspeed

codspeed Bot commented May 27, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.36%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 12 untouched benchmarks
⏩ 5 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ small 11.7 µs 11.3 µs +4.36%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing 05-27-feat_tsconfig_default_exclude_outdir (9d223c8) with 05-27-feat_tsconfig_transitive_project_references (a18b497)

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 closed this May 27, 2026
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.

1 participant