Skip to content

workspace typecheck: tsconfig.vitest-temp.json is overridden if more workspace target the same folder with a different tsconfigs #7107

Closed
@marcalexiei

Description

@marcalexiei

Describe the bug

Using vitest.workspace.ts, I cycle through all the folders in the tests directory.
For each folder, I check for the existence of a file starting with tsconfig.
For each matching file, I create a workspace with test.typecheck.tsconfig referencing the corresponding config file.

Caution

When running vitest, I expect each case folder to contain two temporary tsconfig.vitest-temp files.
Currently, only one is present.

Note

It looks like that thetsconfig.vitest-temp.json name iswritten here:

const tempConfigPath = join(
dirname(tsconfig.path),
'tsconfig.vitest-temp.json',
)

Maybe the issue can be fixed by using the original filename alongside original-name-without-extenstion.vitest-temp.json?

The original issue was reported in i18next repository

Reproduction

I setup a small repository where the issue can be easily reproduced:
https://github.com/marcalexiei/vitest-typecheck-ts-config-reproduction

To show this behaviour I created a GitHub action.
An example run can be found at this page

When running the case-1 workspace, no errors are produced.
However when running case-1-noStrict workspace alone results in an error.

Running all workspaces produces inconsistent results:

  • No errors
  • Workspaces within the same folder show either errors or no errors, depending on which of the two tsconfig files is written in the temp file
  • Parsing errors occur with the tsconfig.vitest-temp.json file

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M3
    Memory: 348.19 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
    pnpm: 9.15.0 - ~/.nvm/versions/node/v22.11.0/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.205
    Safari: 18.2
  npmPackages:
    vitest: 2.1.8 => 2.1.8

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions