I defined my own type and extended it to UserConfig.
... import type { InlineConfig } from 'vitest'; import type { UserConfig } from 'vite'; interface VitestConfigExport extends UserConfig { test: InlineConfig; } ...
Then I casted the type of config object to my custom interface -
export default defineConfig({ plugins: [solidPlugin()], server: { port: 3000, }, test: { environment: 'jsdom', globals: true, transformMode: { web: [/\.[jt]sx?$/], }, setupFiles: './setupVitest.ts', }, build: { target: 'esnext', }, } as VitestConfigExport);
This also enabled intellisense for new test property. Also, you don't need to define /// <reference types="vitest" />.
import { defineConfig } from 'vitest/config';defineConfigfromvitest/configfixes the problem withtest: {...}, but introduces problems in other areas (.e.g'polyfillDynamicImport' does not exist in type 'BuildOptions'). Multiple IDE's give me the same warning even after restart.