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

bun run check fails with "Type 'Promise<Plugin_2[]>' is not assignable to type 'PluginOption'." #10802

Closed
codinkai opened this issue Sep 28, 2023 · 16 comments

Comments

@codinkai
Copy link

codinkai commented Sep 28, 2023

Describe the bug

Hi,
I have setup a new sveltekit project with typescript and prettier enabled.

When I run bun run check, I get the error below.

What can I do to get rid of this error?

Reproduction

npm create svelte@latest my-app
cd my-app
npm install
npm run check

Logs

====================================
Loading svelte-check in workspace: /Users/kai/Desktop/my-app
Getting Svelte diagnostics...

/Users/kai/Desktop/my-app/vite.config.ts:5:12
Error: No overload matches this call.
  The last overload gave the following error.
    Type 'Promise<Plugin_2[]>' is not assignable to type 'PluginOption'.
      Type 'Promise<Plugin_2[]>' is not assignable to type 'Promise<false | Plugin_2<any> | PluginOption[] | null | undefined>'.
        Type 'Plugin_2[]' is not assignable to type 'false | Plugin_2<any> | PluginOption[] | null | undefined'.
          Type 'Plugin_2[]' is not assignable to type 'PluginOption[]'.
            Type 'Plugin_2' is not assignable to type 'PluginOption'.
              Type 'Plugin_2' is not assignable to type 'Plugin_2<any>'.
                Types of property 'apply' are incompatible.
                  Type '"build" | "serve" | ((this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined'.
                    Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                      Type '(this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                        Types of parameters 'config' and 'config' are incompatible.
                          Type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig'.
                            Types of property 'plugins' are incompatible.
                              Type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                                Type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption[]'.
                                  Type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption'.
                                    Type 'Plugin_2<any>' is not assignable to type 'PluginOption'.
                                      Type 'Plugin_2<any>' is not assignable to type 'Plugin_2'.
                                        Types of property 'apply' are incompatible.
                                          Type '"build" | "serve" | ((this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined'.
                                            Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                                              Type '(this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                                                Types of parameters 'config' and 'config' are incompatible.
                                                  Type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig'.
                                                    Types of property 'plugins' are incompatible.
                                                      Type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                                                        Type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[]'.
                                                          Type 'import("/Users/kai/Desktop/my-app/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("/Users/kai/Desktop/my-app/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption'.
                                                            Type 'Promise<false | Plugin_2 | PluginOption[] | null | undefined>' is not assignable to type 'PluginOption'.
                                                              Type 'Promise<false | Plugin_2 | PluginOption[] | null | undefined>' is not assignable to type 'Promise<false | Plugin_2<any> | PluginOption[] | null | undefined>'.
                                                                Type 'false | Plugin_2 | PluginOption[] | null | undefined' is not assignable to type 'false | Plugin_2<any> | PluginOption[] | null | undefined'.
                                                                  Type 'Plugin_2' is not assignable to type 'false | Plugin_2<any> | PluginOption[] | null | undefined'. 
export default defineConfig({
	plugins: [sveltekit()],
	test: {


====================================
svelte-check found 1 error and 0 warnings in 1 file
error: script "check" exited with code 1 (SIGHUP)

System Info

System:
    OS: macOS 11.7.10
    CPU: (4) x64 Intel(R) Core(TM) i5-4308U CPU @ 2.80GHz
    Memory: 72.07 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.17.1 - /usr/local/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/local/bin/npm
    pnpm: 8.6.3 - /usr/local/bin/pnpm
    Watchman: 2023.09.04.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 117.0.5938.92
    Safari: 16.6
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.1.0 
    @sveltejs/kit: ^1.20.4 => 1.25.1 
    svelte: ^4.0.5 => 4.2.1 
    vite: ^4.4.2 => 4.4.9

Severity

annoyance

Additional Information

No response

@eltigerchino
Copy link
Member

npm create svelte@latest my-app
cd my-app
npm install
npm run check

I can't reproduce the issue with these instructions. Please provide a proper minimal reproduction in the form of a downloadable repository.

@codinkai codinkai changed the title npm run check fails with "Type 'Promise<Plugin_2[]>' is not assignable to type 'PluginOption'." bun run check fails with "Type 'Promise<Plugin_2[]>' is not assignable to type 'PluginOption'." Sep 29, 2023
@codinkai
Copy link
Author

codinkai commented Sep 29, 2023

I am so sorry. My instructions were wrong. I have tested out bun for this example. As I thought it is a "drop-in" replacement for node, I assumed the instructions should be same. But I cannot reproduce it with node as well.

curl -fsSL https://bun.sh/install | bash
bun create svelte@latest my-app
cd my-app
bun install
bun run check

When creating the app I selected the following options:

bun create svelte@latest my-app-3

create-svelte version 5.1.0

┌  Welcome to SvelteKit!
│
◇  Which Svelte app template?
│  SvelteKit demo app
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◇  Select additional options (use arrow keys/space bar)
│  Add ESLint for code linting, Add Prettier for code formatting, Add Vitest for unit testing
│
└  Your project is ready!

@Conduitry
Copy link
Member

Issues that arise only with Bun are not something we can afford to try help debug. Bun may have reached 1.0, but a lot of it is still very likely to be unstable or not working yet. If it's operating in a mode that says it's a drop-in replacement and it's behaving differently than Node, that sounds like an issue on Bun's end.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2023
@sanieldalib
Copy link

+1

1 similar comment
@ruizuikeda
Copy link

+1

@codinkai
Copy link
Author

Screenshot 2023-10-14 at 11 50 52

The issue is resolved. Does not occur in bun version 1.0.6 anymore.

Also, see oven-sh/bun#5677.

@AlbertMarashi
Copy link

Hmm I still seem to be getting it even on the latest version of bun

@AlbertMarashi
Copy link

import { sveltekit } from "@sveltejs/kit/vite"
import { defineConfig } from "vitest/config"
import arraybuffer from "vite-plugin-arraybuffer"

export default defineConfig({
    plugins: [
        sveltekit(),
        // used for importing fonts in satori /api/og/+server.ts
        arraybuffer(),
    ],
    test: {
        include: ["src/**/*.{test,spec}.{js,ts}"],
    }
})

This is specifically happening when I use the vitest/config

@dually8
Copy link

dually8 commented Dec 13, 2024

I'm getting the same error in a brand new sveltekit project using the sv cli.

Terminal Output
 ~\Desktop
󱎫 4.519s  5:12PM ➜ pnpm dlx sv@latest create
┌  Welcome to the Svelte CLI! (v0.6.7)
│
◇  Where would you like your project to be created?
│  my-app
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with Typescript?
│  Yes, using Typescript syntax
│
◆  Project created
│
◇  What would you like to add to your project? (use arrow keys / space bar)
│  prettier, eslint, vitest, playwright, tailwindcss
│
◇  tailwindcss: Which plugins would you like to add?
│  none
│
◇  Which package manager do you want to install dependencies with?
│  pnpm
│
◆  Successfully setup add-ons
│
◆  Successfully installed dependencies
│
◇  Successfully formatted modified files
│
◇  Project next steps ─────────────────────────────────────────────────────╮
│                                                                          │
│  1: cd my-app                                                            │
│  2: git init && git add -A && git commit -m "Initial commit" (optional)  │
│  3: pnpm dev --open                                                      │
│                                                                          │
│  To close the dev server, hit Ctrl-C                                     │
│                                                                          │
│  Stuck? Visit us at https://svelte.dev/chat                              │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
└  You're all set!

 ~\Desktop
󱎫 27.876s  5:13PM ➜ cd .\my-app\
 ~\..\my-app                                                                                                                                                                                 󰋁 pnpm   20.14.0
 5:13PM ➜ pnpm check

> my-app@0.0.1 check C:\Users\USERNAME\Desktop\my-app
> svelte-kit sync && svelte-check --tsconfig ./tsconfig.json

If bundling, conditions should include development or production. If not bundling, conditions or NODE_ENV should include development or production. See https://www.npmjs.com/package/esm-env for tips on setting conditions in popular bundlers and runtimes.

====================================
Loading svelte-check in workspace: c:\Users\USERNAME\Desktop\my-app
Getting Svelte diagnostics...

c:\Users\USERNAME\Desktop\my-app\vite.config.ts:5:12
Error: No overload matches this call.
  The last overload gave the following error.
    Type 'Promise<Plugin<any>[]>' is not assignable to type 'PluginOption'.
      Type 'Promise<Plugin<any>[]>' is not assignable to type 'Promise<false | Plugin<any> | PluginOption[] | null | undefined>'.
        Type 'Plugin<any>[]' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.
          Type 'Plugin<any>[]' is not assignable to type 'PluginOption[]'.
            Type 'Plugin<any>' is not assignable to type 'PluginOption'.
              Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").Plugin<any>' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").Plugin<any>'.
                Types of property 'apply' are incompatible.
                  Type '"serve" | "build" | ((this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").Conf...' is not assignable to type '"serve" | "build" | ((this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined'.
                    Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"serve" | "build" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                      Type '(this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                        Types of parameters 'config' and 'config' are incompatible.
                          Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig'.
                            Types of property 'plugins' are incompatible.
                              Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                                Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption[]'.
                                  Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption'.
                                    Type 'Plugin<any>' is not assignable to type 'PluginOption'.
                                      Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").Plugin<any>' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").Plugin<any>'.
                                        Types of property 'apply' are incompatible.
                                          Type '"serve" | "build" | ((this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined' is not assignable to type '"serve" | "build" | ((this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").Conf...'.
                                            Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"serve" | "build" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                                              Type '(this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig, env: import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                                                Types of parameters 'config' and 'config' are incompatible.
                                                  Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").UserConfig'.
                                                    Types of property 'plugins' are incompatible.
                                                      Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                                                        Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption[]'.
                                                          Type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@6.0.3_jiti@1.21.6_yaml@2.6.1/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("C:/Users/USERNAME/Desktop/my-app/node_modules/.pnpm/vite@5.4.11/node_modules/vite/dist/node/index").PluginOption'.
                                                            Type 'Promise<Plugin<any> | FalsyPlugin | PluginOption[]>' is not assignable to type 'PluginOption'.
                                                              Type 'Promise<Plugin<any> | FalsyPlugin | PluginOption[]>' is not assignable to type 'Promise<false | Plugin<any> | PluginOption[] | null | undefined>'.
                                                                Type 'Plugin<any> | FalsyPlugin | PluginOption[]' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.
                                                                  Type 'Plugin<any>' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.
export default defineConfig({
        plugins: [sveltekit()],



====================================
svelte-check found 1 error and 0 warnings in 1 file
 ELIFECYCLE  Command failed with exit code 1.

@ryanzec
Copy link

ryanzec commented Dec 14, 2024

Getting the same issue with using the defineConfig from vitest/config (using the latest versions for vite / svelte / vitest)

@AlbertMarashi
Copy link

AlbertMarashi commented Dec 14, 2024

@Conduitry this appears to be occuring not just with bun, but also pnpm

Specifically with the defineConfig from vitest/config

Could this be re-opened?

@ryanzec which runtime are you using? bun/pnpm/node?

@ryanzec
Copy link

ryanzec commented Dec 14, 2024

@AlbertMarashi well I am using pnpm however that is not a runtime, that is just a package manager tool, I am using the node runtime

@dummdidumm
Copy link
Member

These issues appear when multiple versions of vite came into your node modules.deduplicate them

@dominikg
Copy link
Member

dominikg commented Dec 14, 2024

one source for multiple versions of vite can be vitest, if you use vite6, you either have to use vitest@beta(^3.0.0-beta.1) or add an override so that vitest@2 uses vite6.

@AlbertMarashi
Copy link

one source for multiple versions of vite can be vitest, if you use vite6, you either have to use vitest@next (^3.0.0-next.1) or add an override so that vitest@2 uses vite6.

Could you provide an example?

I appeared to get this issue straight out of the box with the sv create CLI

Should the package.json produced by the installation, be updated to reflect this?

@dominikg
Copy link
Member

"vitest":"^3.0.0-beta.1" (sorry, i used next tag above, edited now)

re sv cli see sveltejs/cli#353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants