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 install error: No overload matches this call #341

Closed
mxfactorial opened this issue Dec 3, 2024 · 10 comments
Closed

vitest install error: No overload matches this call #341

mxfactorial opened this issue Dec 3, 2024 · 10 comments
Labels
bug Something isn't working upstream

Comments

@mxfactorial
Copy link

version

sv@0.6.6

steps

  1. open a typescript gitpod
  2. select continue button to create a new workspace
  3. wait for the editor to appear
  4. cntrl c the init task to cancel or open a new terminal
  5. rm -rf ./* ./.* to remove directory contents
  6. npx sv create .
  7. y to install sv@0.6.6
  8. choose:
    1. SvelteKit minimal
    2. Typescript syntax
    3. vitest
    4. npm
  9. open vite.config.ts

observed

sveltekit() errors with 'No overload matches this call.'

Screenshot 2024-12-02 at 8 38 16 PM
@manuel3108
Copy link
Member

The core problem here is that we are switching the type for the vite config from vite to vitest and it looks like vitest currently does not support plugins of type Promise<whatever>

// without vitest
import { defineConfig } from 'vite';

// with vitest
import { defineConfig } from "vitest/config";

Still trying to find any relevant issue. Currently only found this discussion in vite repo: vitejs/vite#8509

Look's like the vitest config has not been updated to match vite 6

@manuel3108
Copy link
Member

Did not find anything meaningful, therefore created this issue: vitest-dev/vitest#7014

@manuel3108 manuel3108 added bug Something isn't working upstream labels Dec 3, 2024
@AdrianGonz97
Copy link
Member

The mismatch in types is because vitest reverted support for Vite 6 in 2.1.7.

Types can be fixed by reverting back to 2.1.6 or using pnpm.overrides to force vitest to use Vite 6. Though, I would just ignore the type error for now until they fix things on their end in a new release.

@dominikg
Copy link
Member

dominikg commented Dec 9, 2024

see dominikg/vitest-example-svelte5#1 for a setup that works with vite@6, vitest@3 beta and latest sveltekit/svelte

@qbtf
Copy link

qbtf commented Dec 16, 2024

As far as I could tell, the issue is somehow related npm and does not happen on pnpm. installing vitest of version either "^3.0.0-beta.1" or "~-beta.2" does not resolve the type error issue.

My reproduction:

  1. npx sv create my-app -- select "SvelteKit minimal", "Yes, using Typescript syntax", "vitest" only, and then "npm".
  2. cd my-app.
  3. npm install -D vitest@3.0.0-beta.1 (or beta.2).
  4. Run npm run check.
  5. There is a type error squiggle at the line "plugins: [sveltekit()],".

Edit: Looked into the directory my-app/node_modules/vitest/node_modules/vite. The package.json in it indicates that npm still installs Vite 5.

Edit again: My solution is to include the following in package.json:

{
  /* ... */
  "overrides": {
    "vitest": {
      "vite": "^6.0.0"
    }
  },
}

@Oudwins
Copy link

Oudwins commented Dec 20, 2024

This is still happening with the default sv template. At least on npm. When running npm run check it reports "no overload matches this call" error

Edit: same issue on pnpm....

both on a brand new sv create project with the following dependencies:

  • eslint
  • tailwindcss
  • typescript
  • prettier
  • vitetest

Edit2: the override proposed by @qbtf does not work, at least on pnpm

edit3: package.json for future reference

{
	"name": "svelte5",
	"private": true,
	"version": "0.0.1",
	"type": "module",
	"scripts": {
		"dev": "vite dev",
		"build": "vite build",
		"preview": "vite preview",
		"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
		"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
		"format": "prettier --write .",
		"lint": "prettier --check . && eslint .",
		"test:unit": "vitest",
		"test": "npm run test:unit -- --run && npm run test:e2e",
		"test:e2e": "playwright test"
	},
	"devDependencies": {
		"@eslint/compat": "^1.2.3",
		"@playwright/test": "^1.45.3",
		"@sveltejs/adapter-auto": "^3.0.0",
		"@sveltejs/kit": "^2.9.0",
		"@sveltejs/vite-plugin-svelte": "^5.0.0",
		"autoprefixer": "^10.4.20",
		"eslint": "^9.7.0",
		"eslint-config-prettier": "^9.1.0",
		"eslint-plugin-svelte": "^2.36.0",
		"globals": "^15.0.0",
		"prettier": "^3.3.2",
		"prettier-plugin-svelte": "^3.2.6",
		"prettier-plugin-tailwindcss": "^0.6.5",
		"svelte": "^5.0.0",
		"svelte-check": "^4.0.0",
		"tailwindcss": "^3.4.9",
		"typescript": "^5.0.0",
		"typescript-eslint": "^8.0.0",
		"vite": "^6.0.0",
		"vitest": "^2.0.4"
	},
	"dependencies": {
		"@tailwindcss/forms": "^0.5.9",
		"@tailwindcss/typography": "^0.5.15"
	},
	"overrides": {
		"vitest": {
			"vite": "^6.0.0"
		}
	},
	"packageManager": "pnpm@8.15.6+sha512.77b89e9be77a2b06ad8f403a19cae5e22976f61023f98ad323d5c30194958ebc02ee0a6ae5d13ee454f6134e4e8caf29a05f0b1a0e1d2b17bca6b6a1f1159f86"
}

@dominikg
Copy link
Member

for pnpm it is either resolutions or pnpm.overrides as a key in package.json, see https://pnpm.io/package_json#pnpmoverrides
https://pnpm.io/package_json#resolutions

@Oudwins
Copy link

Oudwins commented Dec 20, 2024

Ah, I see. My bad. I will say that updating to vitest 3.0 beta also works

@qbtf
Copy link

qbtf commented Dec 21, 2024

@Oudwins My solution works only with npm. I think npm is still the de facto standard and a npm package cannot work out-of-the-box is strange.

@manuel3108
Copy link
Member

We have reverted the changes to use vite@6 while creating new projects, since vitest@3 will only be released in January. For newly created projects, this is no longer an issue. All others can use a workaround provided above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

6 participants