#Any workaround to use `types` and `typeRoots` together in tsconfig?

4 messages · Page 1 of 1 (latest)

rose hull
#

I'm using vitest to test my codebase. In order to use vite's global objects, I'm told to add vitest/globals to compilerOptions.types: https://vitest.dev/config/#globals
However, at the same time, I want to make all my own type declarations under src/types global, so that I don't need to import them every time (some of them are really frequently used).
In the past, I would specify typeRoots: ["node_modules/@types", "src/types"], but now I can't do this, because vitest/globals only supports types.
In a word, I'm trying to find a way to both specify types and typeRoots, but they are in conflict. Is there any workaround? Or am I doing some bad practices?

A blazing fast unit test framework powered by Vite

leaden creek
#

doesn't

{
  "compilerOptions": {
    "typeRoots": [
       "node_modules/@types",
       "node_modules/vitest/globals",
       "src/types"
    ]
  }
}

work?

#

@rose hull

#

or

{
  "compilerOptions": {
    "typeRoots": [
       "node_modules/@types",
       "node_modules/vitest",
       "src/types"
    ]
  }
}