TS: Object literals can specify only known properties, and "test" is not in type "UserConfig"

See original GitHub issue

Describe the bug

This is a type error, please tell me the correct solution.

Reproduction

/// <reference types="vitest" />
import type { ConfigEnv, UserConfig } from 'vite'

export default ({ command, mode }: ConfigEnv): UserConfig => {
   return {
      test: {},
   }
}

System Info

mac os

Used Package Manager

yarn

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sheremet-vacommented, Oct 5, 2022

So, this happens when you have several Vite versions installed. Check your lockfile and resolve the inconsistency. You can also bypass this by using defineConfig from vitest/config. Closing issue since this is not Vitest problem.

1reaction
kevinvalkcommented, Sep 5, 2022

Exact same problem here:

yarn list v1.22.19
├─ @vitejs/plugin-vue@3.1.0
├─ @vitest/coverage-c8@0.23.1
├─ vite-plugin-checker@0.5.1
├─ vite-tsconfig-paths@3.5.0
├─ vite@3.1.0
└─ vitest@0.23.1
   └─ vite@3.0.0

One of our devs was so smart to cast the defineConfig({} as Parameters<typeof defineConfig>[0])

Read more comments on GitHub >

github_iconTop Results From Across the Web

'test' does not exist in type 'UserConfigExport', even with ...
I have found a workaround for this problem - creating separate vitest.config.ts file. As docs states: Create vitest.config.ts , which will have the...
Read more >
types/nodemailer 6.2.0 & Typescript 3.5.1 Failure · Issue #35847
Object literal may only specify known properties, and 'host' does not exist in type 'Transport | TransportOptions'. When calling:.
Read more >
Raspberry integration test - Help - Edge Impulse Forum
Object literal may only specify known properties, but 'device' does not exist in type '{ deviceId: string; intervalMs: number; }'.
Read more >
clean-code-typescript - GitHub Pages
When someone looks at the function signature, it's immediately clear what properties are being used. It can be used to simulate named parameters....
Read more >
Configuring Vite
Note if an inline config is provided, Vite will not search for other PostCSS config sources. css.preprocessorOptions #. Type: Record<string, object>. Specify ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found