Skip to content

fix: resolve aliases from referenced tsconfig projects in sibling directories#216

Open
benpsnyder wants to merge 1 commit into
aleclarson:v7from
benpsnyder:fix/referenced-project-resolution
Open

fix: resolve aliases from referenced tsconfig projects in sibling directories#216
benpsnyder wants to merge 1 commit into
aleclarson:v7from
benpsnyder:fix/referenced-project-resolution

Conversation

@benpsnyder

@benpsnyder benpsnyder commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #190.

Summary

When a root tsconfig uses project references (e.g., Nuxt, shared config packages), the referenced configs may live in sibling directories (.nuxt/, .config/) that are never visited by the ancestor directory walk in getResolvers. Imports using aliases defined in those referenced projects fail with configMismatch.

Example: Nuxt generates .nuxt/tsconfig.app.json with path aliases like @: ["../app"]. A file at tests/mytest.ts importing @/something fails because:

  1. The walk from tests/ goes up to the project root
  2. The root tsconfig.json has "files": [] — skipped (no resolver created)
  3. .nuxt/tsconfig.app.json is stored under .nuxt/ in the cache — never visited

Changes

getResolvers — when visiting a directory, also yield resolvers from referenced projects. This surfaces aliases from sibling directories without changing the walk itself.

createResolver — accepts a skipIncludeCheck flag. Referenced resolvers skip the include/exclude check since the parent project's scope applies rather than the reference's narrow include patterns (which typically only cover its own source files).

File Change
src/resolver.ts getResolvers yields referenced resolvers; createResolver supports skipIncludeCheck; unrestrictedResolversByProject WeakMap
test/__fixtures__/referenced-sibling/ Test fixture: root tsconfig with files: [] referencing .config/tsconfig.app.json that defines @/* paths

Test plan

  • New referenced-sibling fixture passes (both tsc and Vite build)
  • All 7 existing test fixtures continue to pass
  • Verify with a real Nuxt project that uses .nuxt/tsconfig.app.json references

…ectories

When a root tsconfig uses project references, the referenced configs may
live in sibling directories (e.g., .nuxt/, .config/) that are never
visited by the ancestor directory walk in getResolvers. This caused
imports using aliases defined in referenced projects to fail with
configMismatch when the importer was outside the reference's directory.

Two changes:
1. getResolvers now yields unrestricted resolvers from referenced
   projects when visiting the parent directory
2. createResolver accepts skipIncludeCheck for referenced resolvers,
   since the parent project's scope applies rather than the reference's
   narrow include patterns

Fixes aleclarson#190.
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