7

Is there any way to use different tsconfig file for vitest?

I have a large project using vue-cli. Before converting it to vite based I first want to use vitest instead of jest. The problem is that the tsconfig.json file is using 'target: es2015' and for vitest it should be 'target: esnext'

coure2011
  • 40,286
  • 83
  • 216
  • 349

2 Answers2

1

Yes, this is possible via the typecheck.tsconfig option in your vitest configuration. This is the relevant part of the documentation.

0

Ideally, we could set a path to a different tsconfig in the vitest configuration. However, I couldn't find such an option.

A workaround that might work in some scenarios would be an inverted pattern:

  • Instead of having a main tsconfig.json to build the project and a tsconfig.test.json to run the tests
  • We could use tsconfig.json for editor support inside the whole project (including tests) and for defining the test tsconfig options (vitest will pick those up)
    • Then use a separate tsconfig.build.json to define only build relevant settings (tsc -p ./tsconfig.build.json)

This allows to limit emitted build output by rootDir, include, etc.

David Wolf
  • 1,400
  • 1
  • 9
  • 18