Skip to content

fix: choose containing tsconfig for monorepo files#79

Open
Egoistian wants to merge 3 commits into
tsperf:mainfrom
Egoistian:codex/tsconfig-selection-monorepo
Open

fix: choose containing tsconfig for monorepo files#79
Egoistian wants to merge 3 commits into
tsperf:mainfrom
Egoistian:codex/tsconfig-selection-monorepo

Conversation

@Egoistian
Copy link
Copy Markdown

Summary

  • extract tsconfig selection into a small pure helper
  • choose the closest tsconfig whose directory contains the target file
  • avoid selecting a sibling package tsconfig when a monorepo package has no local tsconfig
  • add coverage for nearest-match, sibling fallback, node_modules, and Windows-style paths

Why

The previous prefix-based lookup sorted tsconfig files by path length, then returned the first config whose path started with one of the target file's ancestor prefixes. In a monorepo, that can select a sibling package's tsconfig when the target package does not have its own config.

Example:

  • target file: /repo/packages/app-b/src/index.ts
  • configs: /repo/tsconfig.json, /repo/packages/app-a/tsconfig.json

The sibling /repo/packages/app-a/tsconfig.json should not apply to app-b; the workspace root config is the safer fallback.

Verification

  • pnpm typecheck
  • pnpm lint
  • pnpm exec vitest run
  • pnpm build

@Egoistian Egoistian requested a review from danielroe as a code owner May 24, 2026 13:17
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