Test files in TypeScript 6: Paths from tsconfig not resolved without baseUrl

Problem

Test files in a TypeScript project are not resolving imports defined in the paths section of tsconfig.json after removing the deprecated baseUrl option. Source files still resolve correctly, but tests do not. This occurs in IntelliJ IDEA 2026.2 using TypeScript 5.9 and migrating to TypeScript 6. Adding baseUrl back is not viable, as compilation fails with TS5101 (deprecation error).

Cause 

Test files are excluded from the TypeScript project by tsconfig.json settings:

  "include": ["./src/**/*", "./bin/**/*"],
  "exclude": ["./node_modules/", "./dist/", "./tests/"]

As a result, test files are not covered by any tsconfig.json, so IDE features like compilerOptions.paths are not applied to them. With baseUrl, the IDE used a generic resolution root, but without it, path mappings work only for files actually included in the project.

Resolution

Create a separate tsconfig.test.json file for your test files to ensure they are part of a TypeScript project in the IDE. For example, place tsconfig.test.json next to your existing tsconfig.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": { "noEmit": true },
  "include": ["./src/**/*", "./bin/**/*", "./tests/**/*"],
  "exclude": ["./node_modules/", "./dist/"]
}

The exclude override ensures your tests are not excluded, as exclusions are inherited from the base config. This will enable correct path resolution for test files in the IDE, without reintroducing the deprecated baseUrl option.

0 out of 0 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request