#Vite fresh install: TypeScript error for vitest.config.ts

1 messages · Page 1 of 1 (latest)

worldly kernel
#

Hi!

I just made a fresh install of Vite v4.4.2 by using npm init vue@latest.
Sadly I have a TS Error in vitest.config.ts:7

  viteConfig,
  defineConfig({
    test: {
      environment: 'jsdom',
      exclude: [...configDefaults.exclude, 'e2e/*'],
      root: fileURLToPath(new URL('./', import.meta.url)),
      transformMode: {
        web: [/\.[jt]sx$/]
      }
    }
  })
)

The Error says the following.
S2345: Argument of type 'UserConfigExport' is not assignable to parameter of type 'UserConfig | Promise<UserConfig>'.   Type 'UserConfigFn' is not assignable to type 'UserConfig | Promise<UserConfig>'.

Question:

  • Can I fix it, or is it only able inside the Vite Package itself? Is there an Update to fix that?
  • Is it bad to have a TS error (like that) on a fresh install. Should I worry about TS Errors or are they not important?
edgy patrol
#

Can be related to duplicate version of Vite types due to vitest. If you can, remove the lockfile and re-install from sratch you should get only one version of Vite. otherwise force update the other lib that bring a duplicate of Vite

worldly kernel
#

Hi Arnaud!

I did a reinstall without Lock file as you mentioned. Also tried to update both Versions.
Unfortunately without Success. 😦

I cant see that mergeConfig expects "UserConfig" as a Param:
export declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;

But as I understand (?), UserConfigExport should be compatible to UserConfig:

export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;

I used npm init vue@latest.
Should I write an Issue on Vite Github? Or is there something else I can do to solve the Issue myself?

rotund lark