Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest does not work with ${configDir} and references of tsconfig.json #7420

Open
6 tasks done
Lukinoh opened this issue Feb 4, 2025 · 4 comments
Open
6 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) upstream

Comments

@Lukinoh
Copy link

Lukinoh commented Feb 4, 2025

Describe the bug

It seems that ${configDir} is not recognized by vitest when used through references of tsconfig.json.

Reproduction

https://github.com/Lukinoh/repro-configdir-bug-vitest/

Steps to reproduce

  • git clone [email protected]:Lukinoh/repro-configdir-bug-vitest.git
  • cd repro-build-watch-vite-plugin-dts
  • npm install
  • npm run test // Everything works here
  • Open tsconfig.json
  • Remove one / at line 5
  • npm run test // 💥, it does not work

Additional details

To highlight the issue, I added a library that uses experimentalDecorators.
It allows me to detect whether the correct tsconfig.json is used or not.
If there is an error, it means that experimentalDecorators is false.
Hence, it is not using the compilerOptions of tsconfig.vi-XXX.json.

I suspect that something is not able to correctly interpret the ${configDir} when used in conjunction with references of the tsconfig.json.
If I rename tsconfig.vi-configdir.json to tsconfig.json, it works.

System Info

System:
  OS: Linux 5.15 Pengwin 12 (bookworm)
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 18.23 GB / 31.22 GB
  Container: Yes
  Shell: 5.2.15 - /bin/bash
Binaries:
  Node: 20.14.0 - ~/.local/state/fnm_multishells/53724_1738653097445/bin/node
  Yarn: 1.22.19 - ~/.local/state/fnm_multishells/53724_1738653097445/bin/yarn
  npm: 10.7.0 - ~/.local/state/fnm_multishells/53724_1738653097445/bin/npm
  pnpm: 9.15.4 - ~/.local/state/fnm_multishells/53724_1738653097445/bin/pnpm
  bun: 1.0.1 - ~/.bun/bin/bun
npmPackages:
  vitest: 3.0.5 => 3.0.5

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Feb 5, 2025

I think Vite also fails, so either an upstream bug or invalid usage. How can I confirm tsc supports this ${configDir} usage?
Here is a Vite repro https://stackblitz.com/edit/github-jbcdpwek?file=src%2Fa.ts

Vite internally uses tsconfck and it appears to have configDir support already dominikg/tsconfck#188, dominikg/tsconfck#167

(Created an upstream issue dominikg/tsconfck#210)

@hi-ogawa hi-ogawa added upstream p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Feb 5, 2025
@Lukinoh
Copy link
Author

Lukinoh commented Feb 5, 2025

Thank you for giving a look.
My bad, I missed the fact the error was downstream.
A bit frustrating because I did check with vite, but I didn't look in the web console 🤦.

How can I confirm tsc supports this ${configDir} usage?

I have adapted the Stackblitz: https://stackblitz.com/edit/github-jbcdpwek-1nnhrvjc?file=ts-config.vi-configdir.json
I added a npm run build that will just rely on tsc.
In ts-config.vi-configdir.json you can change the extends to see that ${configDir} is correctly taken into account.

@dominikg
Copy link
Contributor

dominikg commented Feb 6, 2025

added a fix for this in [email protected], which still needs to land in vite.

This might not 100% fix it in vitest as it is also using get-tsconfig here:

import { getTsconfig as getTsconfigContent } from 'get-tsconfig'

@Lukinoh
Copy link
Author

Lukinoh commented Feb 6, 2025

Thank you.

It is used only if "typecheck" is enabled from what I saw.
So for my use case, the function will never be called, because I am not using it.

However, could be worth to check with "typecheck" enabled indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) upstream
Projects
None yet
Development

No branches or pull requests

3 participants