Skip to content

V23: relative path in extends field of tsconfig.json does not work as expected. #636

@Ailrun

Description

@Ailrun
  • Issue
    Suppose that we have following directory structure.
project
|- config
   |- jest.config.js
   |- tsconfig.base.json
   |- tsconfig.dev.json
   |- tsconfig.test.json
|- test
   |- test1.ts
   |- tsconfig.json
| - tsconfig.json

And also suppose that tsconfig.dev.json and tsconfig.test.json extend ./tsconfig.base.json, jest.config.js have following content.

module.exports = {
  errorOnDeprecated: true,
  globals: {
    'ts-jest': {
      tsConfigFile: './config/tsconfig.test.json',
    },
  },
  moduleFileExtensions: [
    'js', 'jsx', 'json', 'ts', 'tsx',
  ],
  rootDir: '../',
  testMatch: [
    '<rootDir>/test/**/*.ts',
  ],
  transform: {
    '^.+\\.tsx?$': 'ts-jest',
  },
};

For this case, running tsc -p config/tsconfig.dev.json in project directory works well, but jest --config=./config/jest.config.js does not work with error

Some errors occurred while attempting to read from <project directory>/config/tsconfig.test.json: error TS5058: The specified path does not exist: '<project directory>/tsconfig.base.json'.

IMO, this problem probably came from following line,

path.resolve(rootDir),

which is changed in e5ad58e

  • Expected behavior

tsconfig.test.json reads <project directory>/config/tsconfig.base.json

  • Output from your debug log
    I tried test with TS_JEST_DEBUG="true", but debug.txt file does not generated.

  • Link to a minimal repo that reproduces this issue

  • Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo

This allows potential solutions to be tested against the minimal repo. This saves everyone time and avoids a lot of back and forth.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions