vitesveltesveltekitvitest

SvelteKit: "No overload matches this call" error invite.config.js when working with vitest


I just created an app with pnpx sv create sveltekit-test2

and checked vitest

and now when I run pnpm check I get this error:

Loading svelte-check in workspace: /home/sas/devel/apps/dgiit/proyectos/tmp/sveltekit-test
Getting Svelte diagnostics...

/home/sas/devel/apps/dgiit/proyectos/tmp/sveltekit-test/vite.config.ts:5:12
Error: No overload matches this call.
  The last overload gave the following error.

this is my vite.config.js

import { defineConfig } from "vitest/config";
import { sveltekit } from '@sveltejs/kit/vite';

export default defineConfig({
    plugins: [sveltekit()],

    test: {
        include: ['src/**/*.{test,spec}.{js,ts}']
    }
});

and here's the same error on vscode

enter image description here

the defineConfig from the vite package works ok, btw

enter image description here


Solution

  • This is probably a compatiblity issue between Vitest and Vite 6. See this comment:

    As @dummdidumm mentioned, this is an issue of having multiple Vite versions. vitest just recently reverted their Vite 6 support in their v2.1.7 release, causing Vite 5 & 6 to be installed and the types to be mismatched

    Reverting Vite to v5 might work, I have also seen somewhere that the Vitest v3 beta also fixes this.

    This should just be a type error, so you could probably ignore it using an instruction like // @ts-expect-error.