Skip to content

paths are not resolved in Solution Style (Project References) setup unless explicitly listed in project array #474

@hypensterisk

Description

@hypensterisk

I am using a standard Vite + TypeScript setup which uses the "Solution Style" configuration (a root tsconfig.json that references tsconfig.app.json and tsconfig.node.json).

According to the [README](https://www.npmjs.com/package/eslint-import-resolver-typescript), using an array of projects is "discouraged in favor of references supported".

However, when I follow this advice and omit the project setting (or point it strictly to the root tsconfig.json), the resolver fails to read the paths defined in the referenced tsconfig.app.json. It appears the resolver does not traverse/merge the paths from the referenced projects into the current context.

To make it work, I am forced to use the "discouraged" array approach.

Reproduction

File Structure:

/
├── tsconfig.json (Root)
├── tsconfig.app.json (Contains paths)
├── tsconfig.node.json
└── src/
    └── components/
        └── StateButton.tsx

1. Root tsconfig.json

{
  "files": [],
  "references": [
    { "path": "./tsconfig.node.json" },
    { "path": "./tsconfig.app.json" }
  ]
}

2. tsconfig.app.json (Where paths are defined)

{
  "compilerOptions": {
    "paths": {
      "@components/*": ["./src/components/*"]
    }
    // ... other options
  },
  "include": ["src/**/*"]
}

3. ESLint Configuration (eslint.config.js)
FAILING CONFIG (Following README advice):

settings: {
  'import-x/resolver-next': [
    createTypeScriptImportResolver({
      alwaysTryTypes: true,
      // Omitted 'project' (defaults to root tsconfig.json)
      // OR explicitly set to: project: "tsconfig.json"
    })
  ]
}

WORKING CONFIG (The "Discouraged" workaround):

settings: {
  'import-x/resolver-next': [
    createTypeScriptImportResolver({
      alwaysTryTypes: true,
      // Explicitly listing the referenced projects works
      project: [
        'tsconfig.app.json', 
        'tsconfig.node.json'
      ]
    })
  ]
}

Actual Behavior

When using the Failing Config, imports using aliases throw:
import-x/no-unresolved: Unable to resolve path to module '@components/StateButton'

Expected Behavior

The resolver should detect that tsconfig.json uses references, parse the referenced configuration files (tsconfig.app.json), and resolve the paths aliases defined inside them without needing to manually list every project file in the ESLint settings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions