vitest icon indicating copy to clipboard operation
vitest copied to clipboard

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

Open marcalexiei opened this issue 2 months ago • 0 comments

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: https://github.com/vitest-dev/vitest/blob/78b62ffe1dc078d3e48573b3517f19bbeb898726/packages/vitest/src/typecheck/parse.ts#L78-L81 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

marcalexiei avatar Dec 20 '24 03:12 marcalexiei